URL based breadcrumb for Drupal

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>';
}
Related Terms:

Powered by Drupal - Design by Artinet Copyright 2004 Consilium Enterprises LLC (Owned by Andrew M. Riley)