What is a good strategy for duplicating a complex header sitewide?
Permalink 1 user found helpful
OK, I'm pretty experienced with developing websites, but I'm new to concrete5. I have a test site:http://160.129.40.113/ that I'm playing around with. I have a header that I'm pretty happy with, but the site is going to have around 70 pages total and it would be a bear to make this header on every page. I'm also using layouts so consistency would also be a big issue.
If you look at the site linked above, my header has two layouts. The first layout has an image block with a centered image on the left-hand side and a customized search block on the right side (I took out the header text). The second layout has a customized Breadcrumb autonav (I added "You are here:") and a Superfish menu on the right side. I'd like to have this header on every page of the site. Does anyone know a good strategy for accomplishing this? I realize that I may be barking up the wrong tree by using layouts, but I'm just not experienced enough yet to formulate a good plan.
Thanks!
If you look at the site linked above, my header has two layouts. The first layout has an image block with a centered image on the left-hand side and a customized search block on the right side (I took out the header text). The second layout has a customized Breadcrumb autonav (I added "You are here:") and a Superfish menu on the right side. I'd like to have this header on every page of the site. Does anyone know a good strategy for accomplishing this? I realize that I may be barking up the wrong tree by using layouts, but I'm just not experienced enough yet to formulate a good plan.
Thanks!
Thanks for the reply, JohnTheFish! What's tricky is that my header uses layouts. Would your solution still be applicable in this case?
As Jordanlev notes below, stay off layouts. They are best kept as an elastoplast solution for one off layout where you can accept their limitations for just that page, or maybe want to show something on one page before doing it properly. Anything wider in scope, especially if you know your css, then its best to build it as a page type in your theme.
With that in mind, it all depends on when, where and who you want to do the editing of the header as to which options suit.
From a technical point of view, the referenced solutions can work with layouts. But just because you can doesn't mean you should :).
With that in mind, it all depends on when, where and who you want to do the editing of the header as to which options suit.
From a technical point of view, the referenced solutions can work with layouts. But just because you can doesn't mean you should :).
Layouts are for users who don't have control over the theme design and want to insert multiple columns where there's only one. You, as the theme designer (and someone who is experienced with developing websites), should *never* need to resort to using layouts (both conceptually and practically -- because they are a second-class citizen in C5 and don't work in some situations that will annoy the hell out of you as time goes on).
The techniques John listed in his link each have their own place (and he also left out an option I use frequently, which is to display stack blocks directly in your theme templates with <?php Block::getByName('your block name')->display(); ?>).
The decision on which to use depends on 2 factors:
1) What do you want your users to be able to change versus what should always be the same no matter what. Should they be able to remove blocks? Add new blocks? Move them around? Edit the contents of them?
2) Does every page on the site have the same exact header, or can it differ from page to page?
If I were building this site, I wouldn't want users changing that content at all, and I'd want it to be the same across every page in the site. What I'd do to achieve this is basically hardcode everything into my theme's elements/header.php file (so no layouts, and no editable areas):
1) Logo image:
2) Search box: hardcode an html form in there, with an action pointing towards the "search results" page in your site -- seehttp://www.concrete5.org/community/forums/customizing_c5/search-box...
3 & 4) Hardcode some autonav blocks --http://c5blog.jordanlev.com/blog/2012/04/hard-coded-autonav-options...
If you need users to be able to change this stuff as time goes on, or want different headers on different pages, let me know and I'll explain the other options in more detail. But stay off the Layouts :)
The techniques John listed in his link each have their own place (and he also left out an option I use frequently, which is to display stack blocks directly in your theme templates with <?php Block::getByName('your block name')->display(); ?>).
The decision on which to use depends on 2 factors:
1) What do you want your users to be able to change versus what should always be the same no matter what. Should they be able to remove blocks? Add new blocks? Move them around? Edit the contents of them?
2) Does every page on the site have the same exact header, or can it differ from page to page?
If I were building this site, I wouldn't want users changing that content at all, and I'd want it to be the same across every page in the site. What I'd do to achieve this is basically hardcode everything into my theme's elements/header.php file (so no layouts, and no editable areas):
1) Logo image:
2) Search box: hardcode an html form in there, with an action pointing towards the "search results" page in your site -- seehttp://www.concrete5.org/community/forums/customizing_c5/search-box...
3 & 4) Hardcode some autonav blocks --http://c5blog.jordanlev.com/blog/2012/04/hard-coded-autonav-options...
If you need users to be able to change this stuff as time goes on, or want different headers on different pages, let me know and I'll explain the other options in more detail. But stay off the Layouts :)
WOW, that is extremely helpful. Thanks so much for the in-depth explanation and the clear advice on why layouts aren't the solution for this particular problem!
Just wanted to update you to say thanks again. I've made a ton of progress today, and your contributions to the community are a huge reason why.
You're welcome!
Have you discovered Designer Content yet? It's quite useful:
http://www.concrete5.org/marketplace/addons/designer-content/...
Have you discovered Designer Content yet? It's quite useful:
http://www.concrete5.org/marketplace/addons/designer-content/...
http://www.concrete5.org/community/forums/customizing_c5/how-to-aut...