Roots Discourse

Question about base.php


im just wondering how the base.php determines whether to use a sidebar or not.

i made a custom template for my home page, from the custom template file. - my home page was full width. using the col-lg-12 taken from the header file

i then created an about page template from the same custom template. and this page is taking a column of 8 and then one of 4 for the sidebar.

HOW does it know?


It’s in the docs:


Take a look in /lib/config.php. This is where it is generating the classes for both main and sidebar.


Ok, i understand that if the page has a sidebar it wraps it in an 8 col, or otherwise a 12 col,
but if I used the same template to create two separate page templates, why does one have a sidebar and one doesn’t? is it because the home page automatically doesn’t have a sidebar?

sorry to sound so dense. I’m learning more daily, but i do find code a struggle. Im trying to study php via Lynda, but I am finding a lot of the explanations of things are going over my head as they arent explained in context. i know eventually things will click but at the moment it is literally asking for help speaking another language.


Whether the sidebar is displayed or not is controlled by the settings in lib/config.php.

The is_front_page check in the first array will prevent the home page from using a sidebar. If you want to exclude the sidebar from displaying when using your custom template, you need to add the template filename to the second array:



Ok I get it, thanks @Foxaii - the lots of little parts of templates Im just getting to grip with, so if i want to include an image on the page that goes full width, and then have content/sidebar underneath, do i exclude the sidebar and then get the sidebar on the page template? if that makes sense,


so its the following code


    * Page template checks (via is_page_template())
     * Any of these page templates that return true won't show the sidebar

I added 'template-about.php’
not sure if I have put the template in the array correctly?

see my own mistake - it was a comma


No. Edit templates/sidebar.php and put the image inside a conditional check:

<?php if (is_page_template('template-about.php')) : ?>
  <img src="goes/here.png">
<?php endif; ?> 

Or duplicate templates/sidebar.php and rename it templates/sidebar-template-about.php and edit that file directly.


Thank you! Just experienced the same problem. FYI: now controlled via lib/setup.php