1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

The Drupal Content Block and the Omega Theme

Can't Theme Your Content Zone or Region? Enable the Content Block.

By

The Drupal content area, where the text of your article or page goes, has an odd property. It's actually a block.

Like any block, you can place the content block in various regions. Naturally, it defaults to the "Content" region. But you can put it in any region you want. The footer, say.

It might seem odd that the main content is ultimately a block, but then, we expect Drupal to be flexible.

What's really odd is this. If you try to disable this block entirely, so that it doesn't show in any region, the content block won't disappear. No. Instead, the "content block" shows up in the "content region" anyway.

When "Fail-Safe" Behavior Backfires

You might think this is a sensible protection. After all, the content really needs to show, right? No one would ever disable it except by accident. Right?

Maybe so.

However, suppose you're making a subtheme with the Omega base theme. You set up your new theme, and suddenly, you run into an odd problem. The content block seems to resist theming.

The Vanishing Sidebar, or, Expanding Content

You try to put blocks in a right sidebar, but the content section takes up the entire width of the page. The blocks get pushed to the bottom, underneath the content.

You try changing theme settings, clearing caches, reloading, all to no avail. The main content stubbornly fills the whole page.

You don't remember disabling the content block. And of course, there's the content, so you have no reason even to think about blocks.

Finally, you think to use the "Inspect Element" tool and see what's happening in the code. Now you're even more confused! The content zone doesn't seem to be wrapped in any special <div> tags. What is wrong with this theme?

You see a #section-content, but that doesn't help you. The content section holds not only the content, but also the sidebar you're (supposedly) trying to fix.

Where is the <div> for the content zone within this content section? You see a <div> for the sidebar, but not the content zone.

Without a wrapper <div>, there's no CSS. How can the content magically size to Omega's grid? No wonder it's filling the page.

Enable the Content Block

Of course, you already know the solution. Go to the Blocks page, and set the content block to display in the content region. ("Regions" go inside "zones".)

Now refresh your home page. All better. The sidebar should appear just as you expect it to. The problem was the content block -- not the sidebar, and not the theme.

Sure, it seems obvious now. I explained about the Content Block That Will Not Die at the start of the article.

However, it's not nearly so obvious from the other end. You might spend an hour or so trying to figure out why the blasted sidebar keeps sliding under the content. You get no error message, or obvious breakage, or any other sign to suggest that you should be twiddling blocks rather than theme settings.

Has this ever actually happened to me? Perhaps. It needn't happen to you. Just make sure you enable the content block. Done.

Now you can start coding those Omega CSS files.

©2014 About.com. All rights reserved.