peterpp Posted June 30, 2014 Posted June 30, 2014 Hi, I want to add different sidebars for different templates. How to do this? Regards, Pravin
onjegolders Posted June 30, 2014 Posted June 30, 2014 Hi Pravin, That would simply be a case of including a different bit of code for each template. So it could be: home.php // Main content here <?php include("./sidebar.inc"); ?> special.php // Main content here <?php include("./alternate_sidebar.inc"); ?> That's if I'm understanding your question correctly? 2
Nico Knoll Posted June 30, 2014 Posted June 30, 2014 Or do this in your sidebar file: <?php if($page->template->name == 'home') { // show some stuff if home template } elseif($page->template->name == 'page') { // show some other stuff if page template } 2
yellowled Posted June 30, 2014 Posted June 30, 2014 Another option would be to add the various sidebars as (hidden, grouped under a hidden page) pages * Sidebars (hidden) * Sidebar A (hidden) * Sidebar B (hidden) * ... and include them in your templates using a Page field, e.g. called sidebar. Then something like echo $page->sidebar->body; should get you the selected page's body field etc. You could even have this be a Page field which allows to select multiple pages – that way, all pages below Sidebars could be sidebar widgets, and you could add multiple ones to one page. It really depends on what you need and what works best for you (which is usually the case with PW). 2
peterpp Posted June 30, 2014 Author Posted June 30, 2014 Thanx for replies..if-elseif looks good...thanx all...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now