Pedro Posada | Remove Page title based on node type

Remove Page title based on node type

Posted on June 5, 2009 - 3:37pm
<< 19 of 54 >>

Quick and easy php snippet to have the page title not show on only certain node types.

Copy and paste the code below inside your template.php file.

<?php
function mythemename_preprocess_page(&$variables){
    if(
$node = menu_get_object()){
        if(
$node->type == 'my_node_type'){
           
$variables['title'] = '';
        }
    }
}
?>

Works on Drupal 6

Submitted by HS (not verified) on February 8, 2010 - 7:45am.

Where does this go?

An example of how you have implemented this on your page.tpl file will be handy.

Submitted by pedro on February 8, 2010 - 1:02pm.

The code goes in the /sites/themes/mytheme/template.php file.

This is for drupal 6.

You don't have to modify the page.tpl.php at all. The prepocess function can modify all the variables in the page.tpl.php before they are printed out.

Hope this helps.

Submitted by bulat (not verified) on October 2, 2011 - 11:31am.

Solution that worked for me was

1. replace title output in page.tpl.php with this

<?php
if (!empty($node)) print ($node->type)
?>

-title" id="page-title">
<?php
print $title;
?>

2.add to style.css

.-title {display:none;}

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.