I am still relatively new to Drupal, with barely 12 months of experience. I built my first site on a subtheme of Zen (using the ProsePoint profile), which came with lots of body classes that allowed me to define CSS classes for pages and nodes based on content type and taxonomy, since there were body classes like "node-type-story" and "section-news".
Now I'm working on a new site using a custom subtheme of Danland ... which does not include these great content-type and taxonomy body classes.
I would like to include these types of body classes in my subtheme ... but I have almost no PHP knowledge (though I can copy and paste things in the right place if I have good directions).
I found this: http://drupal.org/node/162485
But I don't know if this is exactly what I need ... and I don't know how to incorporate that code in a way that also maintains the "sidebars-1" and "sidebars-2" body classes that already exist in Danland.
I would greatly appreciate help with this. Thanks!
Comments
If you base your subtheme on
If you base your subtheme on zen you will get all the nifty classes you are after? It's a really powerful theme framework after all.
I can see why you want to base your subtheme on a 'ready' theme. But trust me, stick with zen.
Building from a blank basetheme also gives you good knowledge about the foundations of drupal theming.
Otherwise its good old php that will do it.
-Simon
Try wrapping it with a <div> tag.
OK let me explain, the normal way is to attached a
$body_classesvariable to the body tag so it will dynamically generate a classes based on node type, path, etc..., but in a case that you are using a base theme that overrides the classes for the body, then you have a very few option for targeting a page element in CSS based on dynamically generated css class in the body.You can try first this work around before you dig into other solution:
-- Don't touch the body tag of your base theme, leave it as it was
-- Wrap all the element inside the body of your
page.tpl.phpinto a wrapper div.Example:
<body class="<?php print $danland_custom_body_classes; ?>">
<div class="<?php print $body_classes; ?>"> <!--/This is the inserted div wrapper -->
All The original page element here............
<?php print $closure; ?>
</div> <!--/ this is the closing tag for the div wrapper -->
</body>
Please note that I used the
$body_classesto the wrapper div.Test if it will generate a dynamic classes for the wrapper div
If it generate a classes, then your problem was solved, you can now be able to target the page element base on that dynamic class without modifying any code from your base theme.
instead of the code like this :
body.node-type-news #main {color: blue;
}
You can achieve the same thing with
div.node-type-news #main {color : blue;
}
If this work around don't work for you , then you can now try another method / solution, but I tried this with some theme before and it works for me without a problem.
Thanks
Adolfo G. Nasol
Zen limitation
Drop down menus are not native to Zen (For goodness sake why not?)
It shouldn't take all the extra work to get them in.