Footer Block

Permalink
I have looked around the forums for days, but do not find anwer to if it is possible to insert a block, for example a footer with contact information, that is editable at one page and automatically changed at all pages where it also exists. Copying and pasting with scrapbook seems quite medieval.

 
craftyCS replied on at Permalink Reply
craftyCS
You just need to edit the page type content and apply that to all the pages, it's very easy. I think (without looking) it's inside the pages and themes section under pages and then editt the page type then once you've edited it click on it and choose which pages you want to apply that adress block to.

There is a whole vimeo tutorial on this so just dig around the forum and you should find a link somewhere
Mnkras replied on at Permalink Reply
Mnkras
i would make a new pagetype that has a footer area and then edit the page defaults for that page type
Remo replied on at Permalink Reply
Remo
maar replied on at Permalink Reply
maar
Why not insert a new content block directly in to a scrapbook and then insert that block in to your pages - then when you update the master block in the scrapbook it will be updated on all pages.. Simple...

Regards
Michael
kirkroberts replied on at Permalink Best Answer Reply
kirkroberts
If your footer content will truly be on every page you should put it in your footer.php include file.

I found code similar to the below somewhere else in the forums, but can't remember where. It basically stores the footer Area on your home page (that is where you'd edit it) and reads it in no matter what page you're on. The home page is pretty much always going to have the ID of 1.

$global_footer = Page::getByID(1); 
$ah = new Area('footer');
$ah->setBlockLimit(1); // this is optional
$ah->display($global_footer);


This way you don't have to add blocks to any pages or even page types, it just shows up. Very cool.

Edit - you *do* have to add blocks to your footer Area on the home page. Every other page will automatically get the footer, assuming your footer.php is included in the page type. Just wanted to clarify that.
escribileamauro replied on at Permalink Reply
thanks kirkroberts!! your solution works almost perfectly..the only problem is if you add custom Design (i.e. right click and add some css rules in the Design tab) they won't load !

any workaround for this?

thanks!!
kirkroberts replied on at Permalink Reply
kirkroberts
escribileamauro — I haven't tested that situation, so I'm not what the issue might be or how to solve it. You might try Tony's solution (in this thread) which uses the Scrapbook.
Tony replied on at Permalink Reply
Tony
I normally use global scrapbook blocks for this type of thing, by creating a block within the dashboard/scrapbook page, giving it a unique name, then hard coding something like this into my theme footer:

$block = Block::getByName('MailingListBox'); 
if( is_object($block) ) $block->display();


kirk's solution above is a good one too.
glockops replied on at Permalink Reply
glockops
How would I display an alternative if a block with that name was not found?

Everything I try always executes true - even if the block name doesn't match.

Here's what I would like...
if( is_object($cta) ) {
               echo $cta->display();
            }
            else {
               if( $c->isEditMode() )
                  echo $message = '<span class="editing-notice">
                  <strong>Block Not Found</strong><br />
                  The attribute "<em>' . $c->getCollectionAttributeValue("call_to_action") . '</em>" could not be found in any shared scrapbook. Check the names of the blocks in the shared scrapbook and ensure one block matches the attribute value exactly.
                  </span>';
            }


The if(is_object) always returns true. I think it's because the Block:getByName() is creating a new object even if it can't pull a block by name.

I've tried a ton of different combos and tests (is_null, is_array, is_string, etc) - but still can't get the if statement to fail. Any ideas?
Responsive replied on at Permalink Reply
Responsive
using the following does not seem to update when an edit is made in the scrapbook. I have to disable the cache for the site to make it work, is this correct ?

<?php
 $block = Block::getByName('test1');  
 if( is_object($block) ) $block->display();  
?>
kirkroberts replied on at Permalink Reply
kirkroberts
silko - I'm not sure about that. The c5 caching system is kind of mysterious to me :-) If you want to use the scrapbook — and this issue is real — you could leave caching enabled and just empty it in the Dashboard when you make a footer update. I can see how this would be needlessly cumbersome, though. Have you tried the other solution that I propose in the "answer" to the thread? That might yield different results, and it allows editing of the footer on the front-end of the site.
creativesolutions replied on at Permalink Reply
creativesolutions
I know this is an old post but did you ever find a solution to the global scrapbook cache in the header and footer?
kirkroberts replied on at Permalink Reply
kirkroberts
@creativesolutions as of version 5.5 (I think) you can now use a Global Area which shows up in the Stacks area of the Dashboard. It's basically like this:
<?php 
   $a = new GlobalArea('Area Name');
   $a->setBlockLimit(1); // optionally set a limit on number of blocks that can be added
   $a->display($c);
?>

Not sure if that will solve the issue, but that seems like the "right" way to do it nowadays.