Embed dynamic content (code/snippets/shortcodes…)


#1

Is there any way to embed code in a field? As I remember regions supported PHP code.

I have several pages, where I need dynamic content like a list of child pages or the contact form.


#2

You can always embed code in your fields - whats done with that code then depends on your frontend.

Rendering and layouting is a thing that is formally done within the frontend (which is the spot that receives your cockpit api data) - I guess thats why regions have been removed from the cockpit core.

But if you are looking for the regions module that has been a part of cockpit once take a look at this:

This is the original regions module you used to know back then. Artur just stripped it right out of the core and made a addons out of it. Installing this addon to your cockpit installation will bring back the regions as you know them from previous cockpit versions.

But if you do not like to install this addon you could perhaps use repeaters or collection-links in order to represent child views/pages


#3

What if the client wants to insert something like a form within the content? Or a “snippet” with the latest 3 receipts from the “cooking collection”? Or something else you can’t do easily from a markdown/wysiwyg editor.
Thanks for the link anyhow. I will have a look at it.


#4

I guess you could do it like wordpress does. Just give your client the possibility to use some kind of shortcode within his content sections. Something like [RECENT_RECIPS] oder %RECENT_RECIPS%.

You can then parse this string within you frontend and replace it with the dynamic recip list.

I know that is not convenient but at last it solves your needs.

Perhaps a collection link field could also do the trick - but I barely used collection links yet, so this hint is without guarantee.


#5

Yeah, thanks for the hint. I’ll will have a look at plugins. Perhaps I build something for that kind of situation.


#6

the tinymce editor supports an embed feature:

image

maybe a plugin for it that does exactly what you need?

maybe other option is to use the short codes and handle the replacement when retrieving from the api on a collection.find.after