Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I want my sidebars to be 4 column and not 3. I'm not seeing a great way to do this right out of the gate... right now I'm changing out items in the page.tpl.php file. What is the best practice to do this for this theme?
Comments
Comment #1
valkum CreditAttribution: valkum commentedThe easiest way is to create a subtheme with a changed page.tpl.php
Maybe you could create a feature request to include this into theme settings.
Comment #2
mattsmith3 CreditAttribution: mattsmith3 commented@ valkum will do. In the mean time, here's a work-around:
In template.php:
and in page.tpl.php (located in /bootstrap/theme/system/--copied to local subtheme templates folder) you can change you column widths manually like so:
Comment #3
mattsmith3 CreditAttribution: mattsmith3 commentedFeature Request:
https://drupal.org/node/2128129
Comment #4
netikseo CreditAttribution: netikseo commentedMatt, I tried to do as you described and second sidebar becomes 4 columns width, but main content hasn't change into 8 columns, still 9 columns. Any ideas why?
My sub-theme name is "bootstrap_4colsidebar", so I'm using "function bootstrap_4colsidebar_preprocess_page(&$variables) {" Is that right?
I tried to enable both sidebars and then I get regions:
col-sm-4 col-sm-6 col-sm-4, when it should be all col-sm-4
Appreciate your help!
Comment #5
bkno CreditAttribution: bkno commentedIf anyone else couldn't get the preprocess overriding to work (didn't have the time to debug) an alternative is just replacing the section element that relies on $content_column_class in the subtheme's page.tpl:
<section class="<?php if (empty($page['sidebar_first']) && empty($page['sidebar_second'])) { print 'col-sm-12'; } else if (!empty($page['sidebar_first']) || !empty($page['sidebar_second'])) { print 'col-sm-8'; } else { print 'col-sm-4'; } ?>">
I also updated the sidebar widths to col-sm-4.
Comment #6
markhalliwellComment #7
fdefeyter@gmail.com CreditAttribution: fdefeyter@gmail.com commentedSuch a shame we can't change that :-(
Comment #8
BarwonHack CreditAttribution: BarwonHack commented#5 is perfect - thank you so much bkno :)
Comment #9
pradeepjha CreditAttribution: pradeepjha commented#2 worked for me.
Comment #10
bcgarland CreditAttribution: bcgarland commentedIn addition to #5 I also had to edit the following in the page.tpl.php file to reflect the changes in column width.
and
I changed the content class to col-md-8 and sidebars to col-md-4
Comment #11
TheThemerist CreditAttribution: TheThemerist commented#2 Worked here.
As long as your main column mark-up in page.tpl.php contains:
<?php print $content_column_class; ?>
...It should dynamically update to use the correct bootstrap class depending on 1 or 2 sidebars.
Well at least it has for me.
Comment #12
lunk rat CreditAttribution: lunk rat commentedUsing 7.x-3.x-dev (10/2/2014) I simply copied page.vars.php into my subtheme, then renamed the function
function bootstrap_preprocess_page
tofunction mysubthemename_preprocess_page
, then changed the$content_column_class
logic to suit my column width needs, then changed the col-sm values of both elements in page.tpl.phpNothing needed in template.php. Just make sure you change the function name in any *.vars.php files that you override in your subtheme.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedI tried copying the logic from bootstrap_preprocess_page(&$variables) into mytheme_preprocess_page(&$variables) and could not get my changes to take effect. Strangely, when I printed out the variables using dpm() it had a record of my change, but it wasn't actually being applied.
My solution was to change the variable name to content_column_width and update it in my page.tpl.php file.
Comment #14
hockey2112 CreditAttribution: hockey2112 commentedI wanted my secondary sidebar to be 4 columns, so I edited my page.tpl.php file as such...
I changed this: print _bootstrap_content_span($columns); ">
To this:
and I changed this:
To this:
Is this an acceptable/correct solution? Any issues that may arise from this? I don't plan on using a Primary sidebar.
Comment #15
febdao CreditAttribution: febdao commented#2 work for me!
Thanks so much!
Comment #16
smlnkv CreditAttribution: smlnkv commented#2 works fine for Bootstrap 7.x-3.0 and not work for 7.x-3.x-dev (7.x-3.1-beta2). I used hook_process_page instead of hook_preprocess_page. It works for me