Printing pagename and sitename in page.tpl.php
technology-now - July 3, 2009 - 10:03
I'm using Garland and I wanted to change the header title-tag from PAGENAME | SITENAME to just PAGENAME.
I changed part of the page.tpl.php
FROM:
<?php
print $head_title
?>TO:
<?php
print $title
?>THIS WORKED FINE,
Every page except the front page now has the title-tag PAGENAME as I wanted
BUT
My front page shows no title-tag at all.
I want to keep the amended code, and keep the PAGENAME as the title-tag for all other pages,
but I also want to have the SITENAME for the title-tag on my front page.
How do I change my new code to achieve this?
Can anyone help with the correct code?

you can use page_title module
Hello,
you can use page_title module. it provide settings for front page and other pages. you can have different page title instead of node title for the nodes.
Regards,
Pinky
Hi, The $head_title variable
Hi,
The
$head_titlevariable prints the page name, followed by a pipe (|), followed by the site name. The$site_namevariable prints out the site name on it's own in the same way that$titlevariable prints the node title on its own.If you're using Garland, you should have a file
page-front.tpl.php- what is in between the<title>tags here? You should be able to put<?php print $head_title; ?>or<?php print $site_name;?>here, which will hopefully fix that problem.Just to point out that having both the node title and site title is generally seen as best practice for SEO and usability, but it's up to you.
All the best
Dave
"Set a man a flame, keep him warm for a day. Set a man aflame, keep him warm for the rest of his life."
As a PS, when starting I
As a PS, when starting I found this page invaluable:
Also check out the ones for node.tpl.php, comment.tpl.php, etc.
All the best
Dave
"Set a man a flame, keep him warm for a day. Set a man aflame, keep him warm for the rest of his life."
Thanks. I've taken your SEO
Thanks.
I've taken your SEO advice and changed the code back to what it was originally.
I'm also taking your recommendation and will do a bit of bedtime reading.
Thanks everyone.
Cool, glad to be of
Cool, glad to be of help.
Dave
"Set a man a flame, keep him warm for a day. Set a man aflame, keep him warm for the rest of his life."
if you want to do this by
if you want to do this by code, you can try this
<?phpif (drupal_is_front_page()) {
print $site_name;
}
else {
print $title;
}
?>