Context Variables

All Bloqs fields have context variables available. Regardless of what your field or atom names are, the following special variables can be used in your Bloqs field tag pairs. These variables are only available inside of a bloq tag pair (the same level as an atom). For example:

{exp:channel:entries channel="page"}
{my_bloq_field} <!-- This is the Bloqs custom field -->
{content_bloq} <!-- This is a bloq tag pair -->
{heading} <!-- This is an atom inside of a bloq -->
{bloqs:count} <!-- This is one of the context variables below -->
{/content_bloq}
{featured_article_bloq} <!-- Another bloq tag pair -->
{bloqs:count} <!-- This will also work -->
{/featured_article_bloq}
{bloqs:count} <!-- This will not work here -->
{/my_bloq_field}
{/exp:channel:entries}

Please note that as of version 4.4.0, there was a universal change in the Bloqs UI, documenation, and variables of all references of "block" and "blocks" to "bloq" and "bloqs". If upgrading from a version prior to 4.4.0, your old{blocks:total_blocks} variables will still work. For every variable listed below, there is an {blocks:*} alias for it. If you are using a version prior to 4.4.0, then you must use the old variable prefixes, e.g. {blocks:*}

{bloqs:all_vars} List out all of the variables below, and their values in your template for debugging purposes.

{bloqs:id} The unique ID of the bloq being displayed.

{bloqs:count} The count of the current bloq being displayed. The first bloq will have a value of "1", the next "2", etc.

{bloqs:index} The zero-based index of the bloq being displayed. The first bloq will have a value of "0", the next "1", etc.

{bloqs:total_blocks} The total number of bloqs to display.

{bloqs:total_rows} The same as {blocks:total_bloqs} but for people who feel more comfortable with Grid terminology

{bloqs:count:of:type} The count of the current bloq being displayed for this particular type. The first bloq of this type will have a value of "1", the next "2", etc.

{bloqs:index:of:type} The zero-based index of the bloq being displayed for this particular type. The first bloq of this type will have a value of "0", the next "1", etc.

{bloqs:total_bloqs:of:type} The total number of bloqs of the current type to display.

{bloqs:total_rows:of:type} The same as {bloqs:total_bloqs:of:type} but for people who feel more comfortable with Grid terminology

{bloqs:previous:shortname} The shortname of the bloq that precedes the current bloq, or "" if this is the first bloq.

{bloqs:next:shortname} The shortname of the bloq that follows the current bloq, or "" if this is the last bloq.

The following context variables are useful when using a nested bloqs field.

{bloqs:is:first_child} Boolean - If this bloq is the first child of a parent bloq.

{bloqs:is:last_child} Boolean - If this bloq is the last child of a parent bloq.

{bloqs:parent:id} The id of the parent bloq

{bloqs:parent:shortname} The short_name of the parent bloq

{bloqs:children:total_bloqs} If a bloq has children, display how many children it has.

{bloqs:children:total_rows} The same as {bloqs:children:total_bloqs} but for people who feel more comfortable with Grid terminology

{bloqs:siblings:total_bloqs} How many siblings, at the same nesting level, the current bloq has.

{bloqs:siblings:total_rows} The same as {bloqs:siblings:total_bloqs} but for people who feel more comfortable with Grid terminology

:total_bloqs {your_field_name:total_bloqs} returns the number of total bloqs that the field contains. This may be useful for conditionally including the field. E.g., {if "{your_field_name:total_bloqs}" > "0"}.

:total_bloqs - with "type" parameter (optional) {your_field_name:total_bloqs type="shortname"} will return the number of bloqs defined for a particular type, as specified by the bloq type shortname.

Bloq Variables

Bloq variables are an advanced feature. If you add a parameter to your Bloqs field tag pair with the prefix bloq_var_, then the value of that parameter will be made available within your bloq tag pairs. This parameter can override, or workin tandem with the bloq_var's when nesting bloqs.

{exp:channel:entries channel="page"}
{my_bloq_field bloq_var_some_key="some-value"}
{content_bloq}
{heading}
{body_content}
{if bloq_var_some_key == "some-value"}
Do something
{/if}
{/content_bloq}
{/my_bloq_field}
{/exp:channel:entries}