1

How would I get the node type from within a zone/region or section (using omega theme) template file. I know how to override templates at the page/node level for specific content types - but I can't seem to find a variable or anything that points to what type of single, node page content type is currently being displayed.

1
  • 2
    Can you outline what you are trying to accomplish with this? The node templates should carry enough classes on the outer div to do just about anything you want one you get into your region/zone/page templates.
    – mpdonadio
    Commented Oct 25, 2011 at 12:51

2 Answers 2

1

If you are visiting some node then arg(1) call would return node id.

$nid = arg(1);
$node = node_load($nid);
$node->type
1

In your subtheme preprocess template, create a zone or region preprocess file. Let's do an example for region, where you would create the file (example for Omega 3 theme):

{your subtheme directory}/preprocess/preprocess-region.inc

In that file, create your preprocess function that gets the node and adds type to $vars.

<?php
function {theme_name}_alpha_preprocess_region(&$vars) {
  // get the node
  $menu_object = menu_get_object();
  if (isset($menu_object->type)) {
    $vars['node_type'] = $menu_object->type;
  }
}
?>

{theme_name} would be the name of your subtheme. At this point, you can access the variable node_type in your region--content.tpl.php file.

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.