User login
Recent blog posts
- Poor server performance when runing a Drupal site & Flash
- Adding files that begin with a hyphen or dash to Subversion (SVN)
- XML Sitemap Quirks and Module Weight
- May Florida Drupal Meeting
- Firefox 2.x + Mac SWFObject Workaround (White Screen Fix)
- Step by Step guilde to installing the Drupal module Google Analytics
- Drupal Hack Attacks
- Step by step guide to installing the Drupal module Find URL Alias
- Step by Step guide to installing the Drupal module Global Redirect
- Drupal Module: SEO Checklist
URL based breadcrumb for Drupal
Tue, 07/03/2007 - 11:57 — Andrew M Riley
By default the Drupal breadcrumb is very simplistic. It will list breadcrumb like items but if you have a path like www.example.com/news/archive/2007/06 it tends to not really be what I want it to be (I think it should be News > Archive > 2007 > 06).
I created a little snippit that I use in a lot of the sites I create. ***Warning: Minor file editing involved*** Just edit your themes template.php file (if your theme was called blue check out /sites/all/blue/template.php). In the template.php add
function phptemplate_breadcrumb($breadcrumb) {
$uri_request_id = $_SERVER['REQUEST_URI'];
$urlexplode = explode("?", $uri_request_id);
$url = explode("/",$urlexplode[0]);
$args = count($url);
$output = " home";
$path = '';
$replace = array('_','-','+','%20');
// If there is more than one directory or page after home print it
if(isset($url[1]) && $args > 1){
for($x = 1; $x < $args; $x++) {
$text = htmlspecialchars(str_replace($replace,' ',$url[$x])));
if($x < ($args-1)) {
$path .= '/' . urlencode($url[$x]);
$output .= " > <a href=\"" . $path . "\">" . $text . "</a>";
} else {
$output .= " > " . $text;
}
}
}
return '<div id="breadcrumb">' . $output . '</div>';
}
- Andrew M Riley's blog
- Login or register to post comments