
Extend your Page Title using the Drupal breadcrumb path
By using a module like Custom Breadcrumbs we can change the breadcrumb from 'Home > News' to 'Home > News > What are we doing today?'. This is nice, because now we can reflect this setup in our page title as well. If we display a page, Drupal sets the variable $site_title to something like 'What are we doing today? | Site Name' by default.
We can extend this to something more useful like 'Blog » What are we doing today?'. And on your Press overview page, the title could be something like 'Latest news » Press releases'. Ain't that much more useful? To do so, open your page.tpl.php from your themes folder and insert the following code somewhere above the <title> tag:
<?php $crumbs = drupal_get_breadcrumb(); $lastCrumbItem = $crumbs[(sizeof($crumbs)-1)]; $pagetitle = ( trim($title) == trim($lastCrumbItem) ) ? $crumbs[(sizeof($crumbs)-2)] : $lastCrumbItem; $pagetitle = strip_tags($pagetitle); $head_title = $pagetitle ? $pagetitle . ' & ' . $head_title : $head_title; ?>
That's all!
Add new comment