function uc_catalog_nodeapi in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_catalog/uc_catalog.module \uc_catalog_nodeapi()
Implementation of hook_nodeapi().
File
- uc_catalog/
uc_catalog.module, line 157 - Übercart Catalog module.
Code
function uc_catalog_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
static $parents = array();
if (in_array($node->type, module_invoke_all('product_types'))) {
switch ($op) {
case 'view':
if ($a4 == true && variable_get('uc_catalog_breadcrumb', true)) {
$crumbs = array();
if (variable_get('site_frontpage', 'node') != 'catalog') {
$crumbs[] = l(t('Home'), '');
}
$terms = taxonomy_node_get_terms_by_vocabulary($node->nid, variable_get('uc_catalog_vid', 0));
if (count($terms)) {
$crumbs[] = l(variable_get('uc_catalog_name', t('Catalog')), variable_get('uc_catalog_url', 'catalog'));
$used_tids = array();
foreach ($terms as $term) {
if (!isset($parents[$term->tid])) {
$parents[$term->tid] = taxonomy_get_parents_all($term->tid);
}
//drupal_set_message('<pre>'. print_r($parents[$term->tid], true) .'</pre>');
foreach (array_reverse($parents[$term->tid]) as $parent) {
if (!in_array($parent->tid, $used_tids)) {
$crumbs[] = l($parent->name, uc_catalog_path($parent));
$used_tids[] = $parent->tid;
}
}
}
}
drupal_set_breadcrumb($crumbs);
}
break;
}
}
}