Template Tags
Bloqs supports the Template Generator feature of ExpressionEngine 7.5. It'll output all the necessary tags for your Bloqs field. You will of course need to add your html around the tags, but the generated template will give you a jump start.
At the most basic level, templating with Bloqs is nothing more than the standard EE tag pair/tag process. But tag pairs in Bloqs go a bit deeper than what you might normally expect to encounter in ExpressionEngine. Let's take a look at an example so you can see how the logic plays out.
Lets say we have a single bloq type defined with 2 atoms:
Bloq Name: Content Bloq
Bloq Short Name:
{content_bloq}
Bloq Atom Definitions:
Atom Name: Heading
Atom Short Name:
{heading}
Atom Name: Body Content
Atom Short Name:
{body_content}
And this bloq type is added to a Bloqs custom field assigned to the Pages channel.
Field Type: Bloqs
Field Name: My Bloqs Field
Field Short Name:
{my_bloqs_field}
Selected Bloq Types: Content Bloq
Given our base definitions, to output the content in a Pages Channel Entry, your template code would look similar to the following:
A slight more advanced example including a Feature Component bloq:
At the bottom of a Bloqs custom field settings page will be a live basic example template based on the bloqs you've created for your project you can use to get started. Once you've created your basic field tag pairs, you may need to use Context Variables to assist in the rendering of the output. Read more about Context Variables next.
If you are using the bloq nesting feature, then more template examples are available.
Last updated