multiple header issue
Permalink 1 user found helpful
Hi!
I hereby apologize in advance for any ignorance about how to use c5 properly. Just started out and still need to learn a lot of things.
So, the typical absolute basic lay-out for any c5 project apparently is;
So my question now is; What is the best approach when I want to implement a slightly different styled header on another page? My first thought was to create something like header2.php resulting in something like;
I'm not sure if this is the right way to do it? Does anyone has any experience regarding this "multiple headers" issue?
Thanks in advance!
I hereby apologize in advance for any ignorance about how to use c5 properly. Just started out and still need to learn a lot of things.
So, the typical absolute basic lay-out for any c5 project apparently is;
So my question now is; What is the best approach when I want to implement a slightly different styled header on another page? My first thought was to create something like header2.php resulting in something like;
I'm not sure if this is the right way to do it? Does anyone has any experience regarding this "multiple headers" issue?
Thanks in advance!
I'm also doing the header2 thinggie to create a different header. There are some single pages and other resources, but I still do not understand those very well, so I'll stick with the header2 for now.
Any other ideas would be appreciated.
Any other ideas would be appreciated.
Thanks for the fast replies.
FernandoCordeiro, do you happen to remember where I can find these single pages and resources? Would be happy to take a look at them to see if I can get something out of them (when I do I will obviously share it with you in this thread). Thanks in regard
FernandoCordeiro, do you happen to remember where I can find these single pages and resources? Would be happy to take a look at them to see if I can get something out of them (when I do I will obviously share it with you in this thread). Thanks in regard
http://www.concrete5.org/documentation/developers/pages/single-pages/
Lots of info on Simple Pages, good to read...
But it seems like it gets Single Pages from the view.php in your theme, which means they get the header.php
On the other things, I think I found an easy possible answer:
Custom attributes.
Create a custom attribute, for example, "start_page" or anything like that.
Then the elements you want to only load IN that page, you wrap in a condition.
For example: You have a language bar called dinamically from within the header, which gets it from a scrapbook. The block is properly named "lang_bar".
So in the header you must have something like:
So you wrap it in a condition.
Let's suppose you DON'T want this language bar to appear on the page with the "start_page" attribute...
You change the code to:
If instead you want this to happen ONLY IF the page HAS this attribute, you only remove the exclamation from the "if" condition, as shown here:
I think this is a better way to control this kind of behavior. You just make a few edits on your header and make it wall work from scratch.
Now for HTML elements, I'm not sure how to write the PHP function, but I can find that out.
Just let me point, I prefer to use more includes and PHP functions in the template PHP files so I don't have to duplicate content. I usually just include the bits I like. So I created a "body" and a "sidebar" in my elements.php, and assigned the areas to them, this way I can fix things better.
It's NOT the ideal behavior, actually pretty far from it, but it makes way easier for other people to edit the website without the risk breaking anything, so for some clients it is preferable.
Good luck with it. ^^
Lots of info on Simple Pages, good to read...
But it seems like it gets Single Pages from the view.php in your theme, which means they get the header.php
On the other things, I think I found an easy possible answer:
Custom attributes.
Create a custom attribute, for example, "start_page" or anything like that.
Then the elements you want to only load IN that page, you wrap in a condition.
For example: You have a language bar called dinamically from within the header, which gets it from a scrapbook. The block is properly named "lang_bar".
So in the header you must have something like:
<?php $b = Block::getByName('lang_bar'); $b->display(); ?>
So you wrap it in a condition.
Let's suppose you DON'T want this language bar to appear on the page with the "start_page" attribute...
You change the code to:
<?php if(!$c->getAttribute('start_page')) { $b = Block::getByName('lang_bar'); $b->display(); } ?>
If instead you want this to happen ONLY IF the page HAS this attribute, you only remove the exclamation from the "if" condition, as shown here:
<?php if($c->getAttribute('start_page')) { $b = Block::getByName('lang_bar'); $b->display(); } ?>
I think this is a better way to control this kind of behavior. You just make a few edits on your header and make it wall work from scratch.
Now for HTML elements, I'm not sure how to write the PHP function, but I can find that out.
Just let me point, I prefer to use more includes and PHP functions in the template PHP files so I don't have to duplicate content. I usually just include the bits I like. So I created a "body" and a "sidebar" in my elements.php, and assigned the areas to them, this way I can fix things better.
It's NOT the ideal behavior, actually pretty far from it, but it makes way easier for other people to edit the website without the risk breaking anything, so for some clients it is preferable.
Good luck with it. ^^
Little late on my reply, sorry for that. I like your idea about the custom attributes, thanks for explaining so thoroughly what you have done with it. And although it's probably not ideal behaviour like you also stated, for now I can't come up with a 'better' idea.
If you wanted to keep it a bit dryer.