Skip to main content
Tweeted twitter.com/StackDrupal/status/908594005897867266
improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

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.phppage.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.phpin 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!

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' or '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. I haven't been able to get this to work directly in page.tpl.php - and my reading suggests that the best practice is to handle template logic from within 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(). Here 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 consulted this Drupal Stack Exchange post on testing for node type to print a variable from template.php and the Drupal 7 API function description page for template_preprocess_page() and various other sites, and I just can't seem to get this to work. I've seen suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that hasn't worked either. I haven't seen a clear solution posted anywhere, and I'm at my wit's end.

Any help is greatly, greatly appreciated!! Thanks!

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 or 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. I am not able to get this to work directly in page.tpl.php, and my reading suggests the best practice is to handle template logic 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(). This is my code.

<?php
    function MYTHEME_preprocess_page(&$variables) {
        if (!empty($variables['node']) && $variables['node']->type == 'concert') {
            hide($variables['title']);
        }
    }
?>

I read How do I test for node type to print a variable from template.php? and the documentation page for template_preprocess_page(), and various other sites, but I just can't seem to get this to work. I saw suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that didn't work either. I didn't see a clear solution posted anywhere, and I'm at my wit's end.

replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

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' or '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. I haven't been able to get this to work directly in page.tpl.php - and my reading suggests that the best practice is to handle template logic from within 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(). Here 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 consulted this Drupal Stack Exchange post on testing for node type to print a variable from template.phpthis Drupal Stack Exchange post on testing for node type to print a variable from template.php and the Drupal 7 API function description page for template_preprocess_page() and various other sites, and I just can't seem to get this to work. I've seen suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that hasn't worked either. I haven't seen a clear solution posted anywhere, and I'm at my wit's end.

Any help is greatly, greatly appreciated!! Thanks!

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' or '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. I haven't been able to get this to work directly in page.tpl.php - and my reading suggests that the best practice is to handle template logic from within 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(). Here 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 consulted this Drupal Stack Exchange post on testing for node type to print a variable from template.php and the Drupal 7 API function description page for template_preprocess_page() and various other sites, and I just can't seem to get this to work. I've seen suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that hasn't worked either. I haven't seen a clear solution posted anywhere, and I'm at my wit's end.

Any help is greatly, greatly appreciated!! Thanks!

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' or '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. I haven't been able to get this to work directly in page.tpl.php - and my reading suggests that the best practice is to handle template logic from within 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(). Here 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 consulted this Drupal Stack Exchange post on testing for node type to print a variable from template.php and the Drupal 7 API function description page for template_preprocess_page() and various other sites, and I just can't seem to get this to work. I've seen suggestions that you have to call isset() on $variables['node'] before testing for the node type, but that hasn't worked either. I haven't seen a clear solution posted anywhere, and I'm at my wit's end.

Any help is greatly, greatly appreciated!! Thanks!

edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Source Link
Loading