Blocks 1.1.0 Released

A new major version of Blocks has arrived! Blocks 1.1.0 includes the most-requested feature so far—support for native relationships. And in the spirit of the holiday season, there are a few extra stocking stuffers in there, too.

Relationships

Blocks now fully supports Relationships! Whether you want to pull in a photo gallery entry, render a callout to another page, or some crazy idea I can't even imagine, you can now drop a Relationship into any block.

{page_content}
  {simple_content}
    {content}
  {/simple_content}

  {!--
    Pull in an excerpt from another page
  --}
  {related_callout}
    {rel}
      <div class="callout">
        <img src="{rel:header_image:thumb}"
             alt="{rel:header_image_alt}">
        <h2>
          <a href="{rel:page_url}">
            {rel:title}
          </a>
        </h2>
        <p>{rel:excerpt}</p>
        <p class="readmore">
          <a href="{rel:page_url}">
            Read More &raquo;
          </a>
        </p>
      </div>
    {/rel}
  {/related_callout}
{/page_content}

Context Variables

Blocks now has a few extra variables that can help you tailor your templates exactly how you need them.

The first couple you should be familiar with. Just like using Grid, {blocks:index} and {blocks:count} tell you which block you're currently rendering (0- and 1-based, respectively), and {blocks:total_blocks} tells you how many blocks will be rendered.

Sometimes you're concerned with how many of a certain type of block you've rendered. Maybe you want to make the first image of your article larger than the later ones, or the last content block needs some special formatting. For that, there's {blocks:index:of:type}, {blocks:count:of:type}, and {blocks:total_blocks:of:type}.

The last set of context variables let you know which blocks are around the current block. Maybe you want to include special markup when two captioned images come consecutively. {blocks:previous:shortname} and {blocks:next:shortname} will return the types of the previous and next blocks, so your content can adapt accordingly.

And more

Check out the full changelog to see the complete list of changes are included in 1.1.0.