Allowing use of grid classes inside regions

Events happening in the community are now at Drupal community events on www.drupal.org.
matthewv789's picture

As brought up in places like http://drupal.org/node/1245428, it has been difficult to add columns using the same grid system INSIDE of Omega theme regions (using Panels, Display Suite, etc.), since the regions already have grid-x classes themselves, and hence are already 20px narrower than their containers, leaving not enough space for the desired number of columns within them.

I came up with a solution that's fairly easy to use (and pretty generic), but it could be made more elegant if integrated straight into Omega. Here's what I did:

I created a grid-overrides.css file in my sub-theme.

Then I put in overrides like this:

.container-12 .grid-1.no-gutter {
margin: 0;
width: 80px;
}

Then I can add "no-gutter" to the "Additional region classes" in the Omega settings for a region. Then that particular region will be the full width for its number of columns, without the usual 10px gutter on each side. What that means is I can put grid-based columns INSIDE that region (by defining a wrapper around any field and applying a regular "grid-x" class to it, which is easy with Display Suite) and have them fit, as if the region were just a container, not a grid column itself.

I also added this definition:

.add-gutter {
margin: 0 10px;
}

...which I do need to remember to add to any full-width fields within a no-gutter region, but that's not too hard.

Comments

Are you familiar with .alpha

mattfielding's picture

Are you familiar with .alpha and .omega classes and what they do?

Yes

matthewv789's picture

Yes, but what I wanted was to provide generic, repeating, re-orderable fields. I didn't want to have to manually add alpha to the first in each row and omega to the last, or move those classes around if the fields got re-ordered.

Ditto, I assume, with having Panels create columns and other similar instances (though I don't use Panels).

I did have to add some configuration in other places (the no-gutter on the region and possibly add-gutter if I'm putting something full width within that region), but I felt that overall it made configuration easier and was more flexible.

check out the excellent

mattfielding's picture

check out the excellent module Views column Class. http://drupal.org/project/views_column_class if you're using views to output the fields

Cool

matthewv789's picture

Thanks for the link! That certainly looks like a great solution if the main usage of multi-columns is for Views.

(In my case I do need to solve the problem on more than just views, so I may continue using Display Suite to theme my views as well the fields I already ran into this problem with, using the same solution.)

Views column class sounds

samwillc's picture

Views column class sounds promising. So far, I achieved this by adding a custom text into my view, excluded the rest of the fields rewrote in the custom text fields using replacement patterns:

<div class="grid-11 suffix-1 alpha">
<h2>[title]</h2>
[field_intro]
<ul class="inline-links-left">
<li>[view_node]</li>
</ul>
</div>
<div class="grid-12 omega"><div class="portfolio-list-image">[field_preview_image]</div></div>

This view sits inside a 24 column zone and allowed me to get items within one view into the grid rather than straight down the page.

Sam.

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: