0

I've kicked a problem down the road for too long and am now stuck in the fact that I finally need to get it fixed.

I need to program layout changes into the php code so that the right CSS rules can apply to changes based on whether or not the left sidebar and/or the right sidebar is present on the page. In these sidebars are a variety of blocks that I have added to the templates and theme .info file.

So here's an example of my situation. If you need access to my current template files let me know.

So for one page, say I have one side bar the main content area, the css rules would read : Left_Sidebar (width: 33%) and Main_Content (width 66%). But when switching pages, say to one without a sidebar, I want the css rule for Main_Content to be (width: 100%).

I've seen it done on other themes, but this theme is all of my own design. Some examples I've seen are in the "body class" where you see "with-sidebar", "no-sidebar", "two-sidebars" -----

I've tried looking around, but I must be not using the correct terms for what it is I'd like to do. If there is anyone who can help, please let me know! Thank you in advance!

1 Answer 1

1

Many existing themes already provide this kind of feature (usually using a preprocess function) so I would recommend looking at a theme like Zen or another popular base theme for examples of varying the page layout with a body class which specifies the overall structure of the page.

2
  • Would I look in the template,php file? Though thank you for suggesting where to begin searching.
    – Matthew
    Commented Sep 20, 2016 at 21:35
  • Yes unless you have a very large theme it normally makes sense to put preprocess functions in template.php
    – George
    Commented Sep 20, 2016 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.