I am trying to hide the title of the current page (as printed by page.tpl.php
) if the current page is 1) a node in full display (as opposed to teaser mode), AND 2) the node type is either 'concert'concert or 'bio'bio. I print the node title for these content types directly in the node content, so I want to hide the duplicate being printed by page.tpl.php
page.tpl.php. I haven't beenam not able to get this to work directly in page.tpl.php
-page.tpl.php, and my reading suggests that the best practice is to handle template logic from within template.php
in template.php using preprocess and process functions. So, I am trying to hide the current page title (with the above 2 conditions) using template_preprocess_page()
. HereThis is my code (testing for 'concert' node type):.
<?php
function MYTHEME_preprocess_page(&$variables) {
if (!empty($variables['node']) && $variables['node']->type == 'concert') {
hide($variables['title']);
}
}
?>
I've consultedI read this Drupal Stack Exchange post on testingHow do I test for node type to print a variable from template.php? and the documentation page for Drupal 7 API function description page for template_preprocess_page()template_preprocess_page()
, and various other sites, andbut I just can't seem to get this to work. I've seenI saw suggestions that you have to call isset()
on $variables['node']
before testing for the node type, but that hasn't workeddidn't work either. I haven't seendidn't see a clear solution posted anywhere, and I'm at my wit's end.
Any help is greatly, greatly appreciated!! Thanks!