How do I get content from page to page?

Permalink
I'm wanting to do a couple of things here with C5..

First, I have a navigation bar that I want to be on ever page that I create in C5 - I don't want to have to manually add it between pages but I do want to be able to make it editable on every page..

Secondly, I have some text in the header of my website that I want to be displayed on every page as well -- Same thing goes for this text -- I want it to appear in the same area / block and give me the ability to edit / change it on any page I'm on..

Is this possible? If so, how do I accomplish this?

Thanks!

 
ThemeGuru replied on at Permalink Reply
ThemeGuru
Check into the global scrapbook (hardcoded in your theme) and page defaults.
FernandoCordeiro replied on at Permalink Reply
FernandoCordeiro
As ThemeGuru answered, I solved this by hard-coding everything that I need to make appear on all pages.

You can also hard-code things in a more considerate fashion, so you can just use an "if" to check if there is some attribute, for example you want a Twitter block to appear on every page about the company (Just a somewaht poor example), you create an attribute "showTwitter" (Or hideTwitter) and check it out, if it is set (Or not-set incase the attribute hides something) it just executes the code to show the block.


Lastly, to make this "editable", you'll need to add it to a scrapbook and call it by its name. In your case I would create a new Scrapbook for the sake of organization. The one I made was called "FLoatingBlocks", but obviously yours is your to name. You won't even need to remember this for setting things up, just for editing, so give it a name you'd easily recognize and people aren't too prone to mess up.


Then you create the Navigation block, either on the scrapbook already or just move it there and rename it (Inside the crapbook), for example, as "navBlock", and create the text block, naming it as "headerText". Considering you want to show them ALWAYS, I'll just stick with the "hide" attributes, then I'd just call them up with this function:

if(!$c->getAttribute('hide_navBlock')) {
    $b = Block::getByName('navBlock');
    $b->display();
}
if(!$c->getAttribute('hide_headerText')) {
    $b = Block::getByName('headerText');
    $b->display();
}


NOTE 1: !$c = NEGATE $c, which means this getAttribute function returned empty. You'd wanna take the exclamation out if the attribute was to make the BLock appear.

NOTE 2: Notice the:
Block::getByName('nameOfTheBlock');

This means you have to rename this block inside your scrapbook (not sure if there is another option for this function to work, but this way it works perfectly for me).

NOTE 3: You need to hardcode this, so obviously, you gotta edit your theme's php files, inserting the code anywhere you want them to appear. It's pretty easy, but lemme know if you need help with that. I'd suggest inserting them inside a specific Div so if you want to you can style them using that Div with only that specific block inside. Waaay easier.

Good luck. ^^