Change the Breadcrumb of an UberCart Product

For a watch site, we want the breadcrumb for a watch to read

Home >> Brand >> Watch

To do this, we create or edit the theme’s template.php file and add a function.

In this case we have a sub-theme of Marinelli. This has its own breadcrumb function.

We just want to append the brand and let the core-theme function do the rest of the work.

function themename_breadcrumb($variables) {

    $nid = (arg(0) == 'node' && is_numeric(arg(1))) ? arg(1) : FALSE;

    if ($nid) {
        $node = node_load($nid);  

        if (!is_null($node) and ($node -> type == "product")) {

            $brandid = $node -> field_brand\[$node -> language\]\[0\]["tid"];
            $brand = taxonomy\_term\_load($brandid);
            $uri = taxonomy\_term\_uri($brand);
            $url = $uri['path'];
            $variables\['breadcrumb'\]\[\] = l($brand -> name, $url);

        }
    }

    $result = marinelli_breadcrumb($variables);
    return $result;
}

Leave a comment

Your email address will not be published. Required fields are marked *