Reputation: 2792
I am trying to use hook_nodeapi in my template.php file to alter the breadcrumb. I have tried altering the 'if' statement, but it seems as if Drupal is not even using this hook in my template.php.
function gh_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
$productNodeType = 'product';
$tid = preg_replace('#[^\d+]#i', '', $_GET['bc']);
if ($node->type==$productNodeType && $op=='view' && $tid) {
$breadcrumb[] = l(t('Home'), NULL);
if ($parents = taxonomy_get_parents_all($tid)) {
$parents = array_reverse($parents);
foreach ($parents as $p) {
$breadcrumb[] = l($p->name, 'taxonomy/term/'. $p->tid);
}
}
drupal_set_breadcrumb($breadcrumb);
}
}
I found this function (and modified it a bit) from Drupal: Hierarchical taxonomical breadcrumb trail
Upvotes: 2
Views: 994
Reputation: 3550
hook functions go in modules, not themes, so that's why your function isn't being called. On a quick skim, it looks like it should work fine if you move it to module. To do that, make a folder in sites/all/modules with a unique module name, e.g. "modulename", make a file named modulename.info like so:
name = Module Name
description = A module to set breadcrumbs on a product.
core = 6.x
And then make a file named modulename.module starting with <?php
and then your function. Enable the module, and it should start working.
Upvotes: 6