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.
2 Answers
If you are visiting some node then arg(1)
call would return node id.
$nid = arg(1);
$node = node_load($nid);
$node->type
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.