Community Documentation

Remove Page Title on pages with Blog Information block

Last updated October 5, 2007. Created by mfer on May 30, 2007.
Edited by add1sun. Log in to edit this page.

On a blog created by the blog module the page title for the blog reads like "example's blog" where the name (example in this case) is the blog authors username. On these pages you may wish to wish to remove the page title and use the Blog Information block instead.

To do this, in phptemplate, you need to modify your page.tpl.php file. Change:

<?php
print $title;
?>

To:

<?php
if (arg(0) != 'blog' && $node->type != 'blog') { print $title; }
?>

Note: if you do not have a simple print $title; in your theme, but something a little more complex, you simply need to nest the if statement. For example:

<?php
if ($title) {
   if (
arg(0) != 'blog' && $node->type != 'blog') { ?>

      <h1 class="pageTitle"><?php print $title ?></h1>
<?php
  
}
}
?>

This will not display the $title tag on pages that are /blog or have a node type of 'blog'. On all other pages it will be displayed.

Comments

Default title

What about if I need to show "author's blog" like default title? I mean if the bloginfo title is empty...

Thanks

My solution

What I did is to replace <?php print $title; ?>
with this on page-blog.tpl.php :

<?php
                    $block
= module_invoke('bloginfo', 'block', 'view', 0);
                      if (
$block['subject']) {
                       
$output = "<div class=\"bloginfo-block\">\n";
                       
$output .= "<div id=\"bloginfo-block-title\">".$block['subject']."</div>\n";
                       
$output .= "<div class=\"content\">".$block['content']."</div>\n";
                       
$output .= "</div>\n";
                        print
$output;}
                    else print
$title;
                   
?>

On the user's blog page - this will give you the blog-info instead of the the normal title and the normal title if blog-info is empty.

and with this on page.tpl.php :

<?php if ($node->type == 'blog'): ?>
               <div id="blog-title">
   <?php
                    $block
= module_invoke('bloginfo', 'block', 'view', 0);
                      if (
$block['subject']) {
                       
$output = "<div class=\"bloginfo-block\">\n";
                       
$output .= "<div id=\"bloginfo-block-title\">".$block['subject']."</div>\n";
                       
$output .= "<div class=\"content\">".$block['content']."</div>\n";
                       
$output .= "</div>\n";
                        print
$output;}
                    else print
t("@username's blog", array('@username' => $node->name))
                   
?>

                </div>
<?php endif; ?>

Here you replace the title with the blog-info only if the node type is blog, you might want to give it an alternative (else) for nodes that are not blogs.

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here