By Z2222 on
The Omega theme prints out a node's title in region--content.tpl.php which doesn't have access to $node. I tried some modifications, but it's giving me errors:
First, here is the error that I'm getting:
Notice: Undefined index: node in pt_alpha_process_region() (line 34 of /home/*****/public_html/*****/sites/all/themes/pt/template.php).
I want the node's title to be hidden when a "review" content type is displayed. I added this code to region--content.tpl.php:
<?php if($node->type!='review'): ?>
<h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
To get it to work, I added this line to my sub-theme's template.php file:
$vars['node'] = $theme->page['node'];
This is my entire template.php file:
/**
* Implements hook_process_region().
*/
function pt_alpha_process_region(&$vars) {
if (in_array($vars['elements']['#region'], array('content', 'menu', 'branding'))) {
$theme = alpha_get_theme();
switch ($vars['elements']['#region']) {
case 'content':
$vars['title_prefix'] = $theme->page['title_prefix'];
$vars['title'] = $theme->page['title'];
$vars['title_suffix'] = $theme->page['title_suffix'];
$vars['tabs'] = $theme->page['tabs'];
$vars['action_links'] = $theme->page['action_links'];
$vars['title_hidden'] = $theme->page['title_hidden'];
$vars['feed_icons'] = $theme->page['feed_icons'];
$vars['node'] = $theme->page['node'];
break;
case 'menu':
$vars['main_menu'] = $theme->page['main_menu'];
$vars['secondary_menu'] = $theme->page['secondary_menu'];
break;
case 'branding':
$vars['site_name'] = $theme->page['site_name'];
$vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
$vars['site_slogan'] = $theme->page['site_slogan'];
$vars['site_name_hidden'] = $theme->page['site_name_hidden'];
$vars['site_slogan_hidden'] = $theme->page['site_slogan_hidden'];
$vars['logo'] = $theme->page['logo'];
$vars['logo_img'] = $vars['logo'] ? '<img src="' . $vars['logo'] . '" alt="' . $vars['site_name'] . '" id="logo" />' : '';
$vars['linked_logo_img'] = $vars['logo'] ? l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t($vars['site_name'])), 'html' => TRUE)) : '';
break;
}
}
}
The line that is giving me an error is the custom line:
$vars['node'] = $theme->page['node'];
I thought that maybe $node is only on some pages, so I added this, but still get the error:
<?php if($node): ?>
<?php if($node->type!='review'): ?>
<h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
<?php endif; ?>
Any ideas about what I'm doing wrong?
Comments
I would replace
I would replace
with
Thanks
Thank you! That worked...
I want to access to my
I want to access to my $node->field_alttitle[0]['value'] but print nothing.
If I print $node->type prints page and work ok. but I want to print the content of my fields cck.
Thanks.
I ran into a similar problem
I ran into a similar problem trying to rearrange the order of some fields of the node. I was hoping to do show an image field before the title and body fields (like in this example: http://drupal.stackexchange.com/questions/1553/displaying-a-field-before...) but was unable to get it to work in my Omega subtheme.
Any thoughts?
No idea... my thought is to
No idea... my thought is to put the title in the node template, not the section template. The section template doesn't have access to $node. I'm not sure if I'm going to use this theme again because it's too difficult to adjust basic things like breadcrumbs and the title.
It's a great theme, but those two things are making my current project a bit frustrating. :)
Get the NID from the path
I've been struggling with this one too. Here's my little hack version in template.php:
I use that little snip all over the place to harvest the nid ($path[1]) from the URL (I don't put the nid in my URLs and it has made my life unnecessarily difficult). Hope that helps.
my titles only print on the home page
My node titles only print on the home page but none of the other pages. any idea what would cause this?
Thanks
It's work for me! :)
I ran up against this same
I ran up against this same issue just now theming my Omega subtheme. As it happens I am doing a multilingual site using Entity Translation so for that, it's ideal to use the Title module anyway.
<h1 class="title" id="page-title"><?php print $node->title_field[$node->language][0]['safe_value']; ?></h1>Note that I am also using the Delta and Context Modules to enable the traditional page Title on pages like Taxonomy so this is a bit of a Kludge solution.
I can also use this in any node--custom-whatever.tpl.php. The only caveat is that you must use the "replace" function in the UI for the fields settings for any given content type but it's a one time thing.
The solutions above look great but I think this could be a good one too. Hopefully I didn't go down a bad road by doing it this way.
Danny Englander | Twitter | Instagram
A module only solution would
A module only solution would be:
Title
http://drupal.org/project/title
Turns the content types node title into field.
Exclude Node Title
http://drupal.org/project/exclude_node_title
Hides node title for defined entity /content type.