By fiasst-1 on
I need to check if the left and/or right regions are being displayed for the current page.
If I could load the $body_classes variable into my module I could simply search its value for either "left-sidebar", "right-sidebar" or "two-sidebars", but I can't find a way to do this.
Any ideas much appreciated.
Comments
Generally the
Generally the presence/absence of the sidebars happens late in the pipeline, what function are you trying determine this in?
I'm trying to access this
I'm trying to access this from a custom module, block, .tpl file or just about anywhere.
I have a phptemplate_preprocess_page() function in template.php and I've considered setting a session with the available value in there but I'm sure that's not the best practice...
What sort of things are you
What sort of things are you trying to control based on the presence or absence of the sidebars. I am used to controlling css but that does that can already be done.
Yeah, I'm using body_classes
Yeah, I'm using body_classes to manipulate CSS but that isn't enough for the problem im facing. I have nodes in a view which float left of each other in 5 columns if no sidebars are displayed, 4 columns if 1 sidebar is displayed and 3 columns of 2 sidebars are displayed. That's fine but the nodes have a right margin and the last node in each row needs no right margin in order to fit its parent container.
Example:
.node {
margin: 0 10px 10px 0;
}
.node.last {
margin-right: 0;
}
node.tpl
So apparently, if the sidebars are set late on in the pipeline, I'll need to find a clever CSS only solution :\
If they have a fixed width
If they have a fixed width and just float, or are inline-blocks, the divs should fill up all the space available, be it 3 4 or 5 columns worth.
of course you can still set different widths for the three scenarios by checking the body-class
Also, you can get the same spacing effect with using only margin-left, no ?
Well, without going into a
Well, without going into a mass of detail, my problem went beyong CSS and I needed a 1 stop place to check how many nodes to display per row in a view.
I've created a function in a custom module to simply manage this information in one place:
Thanks for your time anyway and explaining that the sidebars are defined late in the process.