Training

Our next U.S. stop:

Mike Anello and Andrew Riley from Mediacurrent are teaming up to offer the first Blue Collar Git workshop on Friday, June 8 as part of DrupalCamp Charlotte (also part of the Southeast LinuxFest). The cost is only $149 for the full day if you register during the month of May ($199 otherwise). 

New Podcast

Posted Wednesday, May 9 at 7:50 am
Brandon Morrison (Brandonian on drupal.org) joins Andrew Riley and Mike Anello on the first post-DrupalCon Denver edition of the podcast to talk about all things Geo in Drupal 7. Brandon is one of the maintainers of the GeoField module and is an active member of the Drupal Geo community.
Download Podcast 82
DrupalEasy_ep82_20120509.mp3
Syndicate content

Newsletter

Stay up-to-date on DrupalEasy workshops and other events. On average, we send about one newsletter per month.

Testimonial

Mike is a great teacher!

Who are we?

DrupalEasy is the collective expertise of Ryan Price and Michael Anello, who joined forces to provide training and consulting services worldwide. Read all about them and what they can do.

What is Drupal?

Drupal is a free, super-powerful content management system for sites that require information posting and collection, including blogs, forums, videos, photos, and databases of information. We think it is the best platform available. Here's why...

Why Drupal?

More and more savvy organizations are going with Drupal for content management, and its no mystery why. It’s free, flexible, and easy to maintain for small or large volume sites. Learn more...

Using Context Module to Set Body Classes

The Context module is a great way to get a site's unwieldy block configuration page under control. It allows you to display individual blocks only when a certain "context" is available.

For example, a context may be set when a particular view is displayed. When that happens, you can use the Context module to display certain blocks alongside the view. If you find yourself writing block visibility code over-and-over again, the context module will save you time and headaches.

One of the other features of the context module is that is lets you add a CSS class to the body tag of a page when a certain context is met. This is a big advantage when you have to theme a page element in particular way only when a particular context is met.

You can find this option on the "edit context" page, in the "theme variables" section. Simply add the class names you want to include in the "section class" text field. You can also override the page title and subtitle from this section.

Trackback URL for this post:

http://drupaleasy.com/trackback/195
No votes yet

More Quicktips


3 comments

Guest wrote 1 year 15 weeks ago

This just doesn't work for

This just doesn't work for me.
Reaction - Theme - Class Section "Smthing"
Reaction - Block - Some blocks

Condition - Path - example/*

If there is site with path example/ex1 it will just add defined blocks, but not the class to body_classes. When i look with firebug there is nothing.

ryanprice wrote 1 year 15 weeks ago

Check your page.tpl.php and

Check your page.tpl.php and make sure your theme has a php print body_classes phrase in the appropriate place. If that doesn't work check the issue queue for context. There are also different versions of context, 2.x and 3.x, and each has its own differing set of bugs.

Guest wrote 1 year 19 weeks ago

Freaking Awesome

Just what I needed! So easy, and saved me from mucking about in the template files.

Syndicate content