Question about base.php


#1

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?


#2

It’s in the docs: http://roots.io/the-roots-sidebar/


#3

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


#4

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.


#5

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:

    array(
      'template-custom.php',
      'template-your-template.php'
    )

#6

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,


#7

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
     */
array(
          'template-custom.php',
    	  'template-about.php',
        )
      );

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


#8

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.


#9

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