Honestly, in all my time with C5, I've never felt the need to do this. But my last post gave me a pretty good reason.

We used Global Areas to create "sectionwide" areas. It works great, but there's one small annoyance... the add text says "Add To Sidewide Product 123 Sidebar". Well, from an editors perspective, it's not "sitewide", it's "productwide". Also, does an editor really need/want to see that cID number?

Fortunately, areas can have attributes, which makes changing the "Add To..." text a pretty quick and safe job.

Step 1: Override Core Area Footer

We need to modify C5 core code. To accomplish this in a "safe" way, we'll take advantage of C5's override system. Copy /concrete/elements/block_area_footer.php to /elements/block_area_footer.php. C5 will now use this copied file instead of the core file.

Open /elements/block_area_footer.php and notice this code at the bottom:

<?php  if ($a->isGlobalArea()) { ?>
    <div id="a<?php echo $a->getAreaID()?>controls" class="ccm-add-block"><?php echo t('Add To Sitewide %s', $arHandle)?></div>
<?php  } else { ?>
	<div id="a<?php echo $a->getAreaID()?>controls" class="ccm-add-block"><?php echo t('Add To %s', $arHandle)?></div>
<?php  } ?>

Replace it with:

    // default add text
	if ($a->isGlobalArea()) {
		$addText = t('Add To Sitewide %s', $arHandle);
	} else {
		$addText = t('Add To %s', $arHandle);
	// optional custom add text
	if ($a->getAttribute('add_text')) {
		$addText = $a->getAttribute('add_text');
<div id="a<?php echo $a->getAreaID()?>controls" class="ccm-add-block"><?php echo $addText; ?></div>	

This keeps the default "Add To..." text, but now allows us to set custom text via an "add_text" area attribute.

Step 2: Set Attribute in Area Definition

Now with a simple line of code, we have custom text.


    $a = new Area('Sidebar');


	$a = new Area('Sidebar');
	$a->setAttribute('add_text', 'This is custom text');

That example was a standard "Sidebar" area. Updated code for last post would be:

    // use navigation helper to get trail ancestor pages
    $nh = Loader::helper('navigation');
    $pageTrail = $nh->getTrailToCollection($c);
    // find main product page by traversing up tree (defaults to current page, replaced if a parent has "product" page type)
    $productMainPage = $c;
    foreach ($pageTrail as $page) {
        // if parent page is of our page type (we know it's "Product", but this avoids typos and possible name changes)
        if ($page->getCollectionTypeHandle() == $c->getCollectionTypeHandle()) {
            $productMainPage = $page;
    // define a unique global area with the main product page's cID
    $a = new GlobalArea('Product ' . $productMainPage->cID . ' Sidebar');
    $a->setAttribute('add_text', 'Add To Productwide Sidebar');