I'm using an Omega sub-theme in Drupal 7. In my front page, I have some sort of "river of news" with all content that has the "promote to the front page" checkbox checked. I would like to create a special front page, so I've copied my page.tpl.php into a new page--front.tpl.php.

I would like to add a special CSS class to that list of content. (The list is filled with all teasers by default.) When I try to target that specific piece of content, I get only this:

<?php print render($page['content']); ?>

Inside that is the content section, and the sidebars sections.

How do I target only the list of teasers?

  • Showing some code would make it easier for people to help you. Like, what are you targeting the class with? JQuery OR CSS could handle pretty much any styling, and if you are getting that in your output something is wrong in your code somewhere, probably the template I would assume. Commented Oct 2, 2012 at 3:10
  • Thanks for your reply! That´s not the output, but the code that´s inside the template. How can I add a specific css class inside that output, but targeting only the content section of the frontpage? The tpl is a copy of the default one.
    – Rosamunda
    Commented Oct 2, 2012 at 3:29

1 Answer 1


The content of the $page array is described in hook_page_alter(), where the documentation says:

The $page array contains top level elements for each block region:

  • $page['page_top']
  • $page['header']
  • $page['sidebar_first']
  • $page['content']
  • $page['sidebar_second']
  • $page['page_bottom']

The 'content' element contains the main content of the current page, and its structure will vary depending on what module is responsible for building the page. Some legacy modules may not return structured content at all: Their pre-rendered markup will be located in $page['content']['main']['#markup'].

Pages built by Drupal's core Node and Blog modules use a standard structure:

  // Node body.
  // Array of links attached to the node (add comments, read more).
  // The node object itself.
  // The results pager.

You can use $page['content']['system_main']['nodes'][$nid]['body'], remembering there is a $page['content']['system_main']['nodes'][$nid]['body'] for each node. Check its structure to see in which way you can add a CSS class to that array.

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.