Share content across site in concrete5

If you worked with concrete5 before you probably know that there’s an in-site editing system where you can place a different kinds of blocks in areas. Usually a page has several areas and your site probably has several pages. This concept might have been a bit uncommon but once you’re used to it, it’s rather powerful and easy to understand as it allows you to edit your site in a layout more or less identical to the layout the site has to visitors.

Placing content in a block works fine but if you wanted to have the same content on several pages it’s going to be a bit tricky. Assume you want to put a certain content in the footer of every page. There used to be a feature called “Scrapbook” which has been replaced by “Stacks”. You can find more information about this on the following page: http://www.concrete5.org/documentation/how-tos/developers/concrete5-5.5-stacks-vs.-scrapbooks/. This is one option you can use, but there’s another one where you can stay on the page you’re editing while amending sitewide content (when editing a “Stack” you’re being redirected to a dashboard page).

When you create your own theme you put this code in it to place an area:

<?php 
$a = new Area('Footer');
$a->display($c);
?>

This works fine but as mentioned in the introduction, you’ll have to put and modify the content of this area on each page of your site. A lot of boring work! One easy change and that’s changed. Just replace the code above with this:

<?php 
$a = new GlobalArea('Footer');
$a->display($c);
?>

Your area will name contain the name “Sitewide” as shown on the screenshot above. Once you add a block you’ll see another hint telling you that this is a global area:

That’s it, there’s nothing else to mention. Everything works like it does in a normal area!




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *