Blocks

Tags

Fieldtype tags

Your field can have many block types defined. When rendering your field, include a section for each type of block.

{your_field_name}

  {short_name_of_block1}
  {!-- This is the code that is rendered for the second block type --}
  <div>
    {shortname_of_atom}
  </div>
  {/short_name_of_block1}

  {short_name_of_block2}
  {!-- This is the code that is rendered for the second block type --}
  <div>
    {shortname_of_atom}
  </div>
  {/short_name_of_block2}

  ...

{/your_field_name}

Context variables

There are some special variables that may be used in your templates.

{blocks:count}
The count of the current block being displayed. The first block will have a value of "1", the next "2", etc.
{blocks:index}
The zero-based index of the block being displayed. The first block will have a value of "0", the next "1", etc.
{blocks:total_blocks}
The total number of blocks to display.
{blocks:total_rows}
The same as {blocks:total_blocks} but for people who feel more comfortable with Grid terminology
{blocks:count:of:type}
The count of the current block being displayed for this particular type. The first block of this type will have a value of "1", the next "2", etc.
{blocks:index:of:type}
The zero-based index of the block being displayed for this particular type. The first block of this type will have a value of "0", the next "1", etc.
{blocks:total_blocks:of:type}
The total number of blocks of the current type to display.
{blocks:total_rows:of:type}
The same as {blocks:total_blocks:of:type} but for people who feel more comfortable with Grid terminology
{blocks:previous:shortname}
The shortname of the block that precedes the current block, or "" if this is the first block.
{blocks:next:shortname}
The shortname of the block that follows the current block, or "" if this is the last block.

:total_blocks

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

Parameters

Type (optional) — {your_field_name:total_blocks type="shortname"} will return the number of blocks defined for a particular type, as specified by the block type shortname.