Best method for having dynamic fields?

I have been wondering what the best ways are to be able to have some sort of dynamic fields for e.g. landing page structured page where there are several different sections having data like text, slideshow, gallery and whatsoever and i was thinking about the ways to get it done.

my attempt would be each section is done as a subpage while

  • snippet (contains html + data output)
  • blueprint contains fields / data entry (need to add to parent page blueprint “template”)
  • template (which basically would just redirect if someone calls the subpage directly)

then my structure will be e.g.

home/
home/gallery
home/section1
home/contact

then calling the snippets in a foreach loop similar to this:

my main issue with this is, having to write a lot of blueprints and having a lot of files
i am also not sure how this would be a pro or con for seo… as url’s for images and stuff

so i am really wondering if there are other attempts to have reusable section/snippets to use in some sort of building process. some sort of a more convenient “add field/data” way of doing it.

Sounds to me like you need the modules plugin

An alternative to the modules plugin would be the page builder plugin. But this can easily get messy if you have many section per page.

From a “having to create many blueprints” perspective, it doesn’t make any difference if you use subpages or modules, because modules are subpages.

From a “SEO-perspective”, modules and subpages are identical as well. However, to avoid file URLs to point to subpages, you could either put these files into the home page folder and select from subpages, or reroute the images.

the modules plugin seems like it’s doing the exact same thing…

if i were to do it like i mentioned above, i’d use it within the plugin and register each blueprint, snippet, and template to have it all sorted together.

is there a drawback uploading them into the “module” subpage? the template itself would just have go($page->parent()->url())

it’s just like the images will have an url like:

domain.ext/home/1-module-whatever-the-uri-is/image123.jpg

That’s why I said, if you want o avoid images to point to subpages, you have to reroute them.

with the modules plugin, everything is stored inside a module subfolder under the parent, so image urls actually look like:

http://domain.test/content/home/modules/1-imagepanel/yourimage.png

You can reconfigure that thought, but thats the recommended way according to the docs.

If you try and hit a page in the modules folder in the browser, the plugin automatically redirects you to the parent page.

The advantages of the modules plugin as compared to using subpages:

  • everything in one place
  • easy way to render all or single modules
  • automatic rerouting of subpages

The modules plugin also works in combination with the pattern plugin

if leaving the image is bad for seo, i would consider rerouting them, otherwise i don’t care … so it’s just a question for good/bad…

i wonder if the modules plugin will be easily compatible in later releases (v3 <3)

Not so sure if we will still need it in v3

Don’t know. Personally, I wouldn’t care.

i would say its not a problem for SEO, for image / file URLS. If you think about it, if you were using a third party CDN for images like Cloudinary, you would have a completely different URL for images anyway. I really do’nt think search engines care where an image comes from, just that it has proper ALT tags etc. That is more important for SEO, along with good image optimisation.

yeah, for convenience i’ll give the plugin a spin

I’d recommend using the modules plugin in conjunction with Kirby-sortable

2 Likes

having issues

installed both plugins
added modules in plugins/modules/content.feature/

does it need to have the filename like content.feature.html.php (especially the .html. part) or or does that not matter at all?

when trying to add the module it does not show as template when adding a subpage, provides only default for me

my content file has the following inside the blueprint:

pages: true
  template: 
    - module.content.slider
    - module.content.location
    - module.content.advantages
    - module.content.beforeafter
    - module.content.feature

You have to create a modules folder in the site folder. See the documentation and the examples.

Demo branch: https://github.com/getkirby-plugins/modules-plugin/tree/demo

i got it.

by accident i put the module templates into the plugin/modules folder.

how do i include logic into the whole thing (instead of the controllers)
EDIT: … “the smart way”, … or is inline fine…