Provide more flexibility for element partial templates #15178
Replies: 4 comments 8 replies
-
Like I suggested during the 5.0 beta, I think the best and most obvious solution would be if entry types had a "Partial Template" setting, similar to the "Template" setting available to sections. |
Beta Was this translation helpful? Give feedback.
-
Agreed. It's too confusing having everything in one place. We have a similar distinction where some are cards that appear within blocks and some are high level blocks. |
Beta Was this translation helpful? Give feedback.
-
Worth mentioning here that CKEditor 4.1.0 is out now, which you complete control over how field values/nested entries are rendered on the front end. You can completely bypass entry partial templates, if you want. (craftcms/ckeditor#241) |
Beta Was this translation helpful? Give feedback.
-
@MoritzLost Created this PR which would allow you to override the rendering: #17189 It could easily be tweaked to check for |
Beta Was this translation helpful? Give feedback.
-
In Craft 5, we have moved our templates for matrix blocks (now entry types) to the folder for element partials, in part as preparation for using embedded entries in CKEditor. However, we've noticed that we can only have one folder for all entry types, regardless of what context or in this case, matrix field, they're used in. This can get a bit messy. In our current use-case, we have two matrix fields – one for sections, and another one for content blocks inside those sections. Previously, the templates for those two hierarchy levels were placed in different folders. Now, they are mixed together, and we can't see at a glance which field a template belongs to. This is a user-level distinction, of course, since all entry types are equal from Craft's point of view. But in terms of AX and DX, there are different types/groups of entries, and we would like to be able to have those in different folders.
The only available option right now is the
partialTemplatesPath
option, but that only allows us to change the base folder, not the folder structure within that folder.Not sure what the best way to solve this would be, but here are some ideas:
elementPartialTemplatePath
(or something like that) that accepts a function as its value. The function would return the path for the twig template. That would allow for custom logic – for example, using different paths based on which matrix fields an entry type is used in.partialTemplatesPath
to a single Twig template file instead of a path. In this case, the one specific template would always be used regardless of element and entry type, and we could include the correct template from a custom folder and implement our custom logic in Twig.Beta Was this translation helpful? Give feedback.
All reactions