Advanced Areas

Advanced Areas

Adding areas to concrete5 themes is very straightforward. With a little know how you can utilize these to your advantage within your theme


Snippet by Andy / / Comments / Difficulty 
Advanced Areas

Area's are fundamental to concrete5 themes; allowing theme designers to set placeholders within page types that allow the website administrator to add blocks when editing the site.

In the pursuit of flexibility within your design, the chances are, you will probably set up a multitude of areas with your page types. Whilst this is great for the administrator it can play havoc with your markup and can leave lots of unwanted div's and empty markup.

When creating your areas in your next theme, consider using the following:

$a = new Area('Area Name');
$areaLayouts = $a->getAreaLayouts($c);
if (($a->getTotalBlocksInArea($c) > 0) || !empty($areaLayouts) || ($c->isEditMode()) ) {
    echo '<div class="your classes">';
    $a->display($c);
    echo '</div>';
}

This snippet tests to see if there are any blocks in the area. If 'true' then your markup is displayed. If 'false', you guessed it; no markup displayed! Furthermore it will display the markup if you are in 'Edit Mode', making it easier to add blocks in the desired design. Lastly, blocks within layouts are also tested for.

 

Join the conversation

comments powered by Disqus