Twig
The following is a basic example of how to render a Bloqs field with nested bloqs.
Note the include statements are passing an array of possible template names to include in the brackets. If the first template file is not found, it will skip it and attempt to render the next one. For example, if you have a bloq named "summary" and you want that bloq to render entirely different HTML, just create a template named _bloq_summary.html
All other bloqs will render in the _bloq.html
template. These template names are completely arbitrary and you can choose any names you want. In this example I have a coilpack.group
folder with the _bloq.html.twig
and _atom.html.twig
templates inside.
entry.html.twig
_bloq.html.twig
_atom.html.twig
If in this scenario there was an atom with the short name of "content_with_image", and a template file named _atom_content_with_image.html.twig
existed, it would be loaded instead of the _atom.html.twig
template.
Twig is extremly flexible and there are probably a number of ways to approach building out a Bloqs field. This is a basic example of how to use an include to render a deeply nested Bloqs field.
@todo Example of a Twig code to render a flat Bloqs field.
Other ways to access atom/field data.
Once you have a bloq variable you can access it's atoms and atom values directly via the dot notation:
Last updated