HowTo:Hide the right sidebar
From MtTWiki
In this HowTo we will modify the Pressblog theme to hide the right sidebar when no blocks exist in it.
Empty sidebar check
We need to check if there is content (blocks) in the right sidebar. Pressblog has one more distinct region over the sidebar, where the tabs area is hosted.
We need to check if there is any content (block) in the following regions:
- Sidebar first
- Sidebar tabs
In case there's no content in the abovementioned region, a specific class "no-sidebar-regions" should be added in the body element of the theme.
The correct place to put the above function is the template.php file, which is located into our themes folder. Usually at "sites/all/themes/pressblog/template.php". More specifically pressblog_preprocess_html functions is the place we are looking for.
function pressblog_preprocess_html(&$variables) { if (empty($variables['page']['sidebar_first']) && empty($variables['page']['sidebar_tabs'])) { $variables['classes_array'][] = 'no-sidebar-regions'; } }
Stylesheet fine tuning
Having the new "no-sidebar-regions" class in our body element we now need to add some CSS rules that will take care of the rest.
We can edit the style.css file of our theme and add the following rules at the end. As an alternative solution, we can use a local.css file. Instructions of how to add a local.css support are available in our HowTo:local.css wiki page.
.no-sidebar-regions #page-inner .grid_8 { width:940px; } .no-sidebar-regions #page-inner .grid_4 { display:none; }