function uc_catalog_node_view in Ubercart 7.3
Implements hook_node_view().
File
- uc_catalog/
uc_catalog.module, line 144 - Ubercart Catalog module.
Code
function uc_catalog_node_view($node, $view_mode) {
static $parents = array();
if (uc_product_is_product($node->type) && isset($node->taxonomy_catalog)) {
if ($view_mode == 'full' && variable_get('uc_catalog_breadcrumb', TRUE)) {
$crumbs = array();
if (variable_get('site_frontpage', 'node') != 'catalog') {
$crumbs[] = l(t('Home'), '');
}
if ($terms = field_get_items('node', $node, 'taxonomy_catalog')) {
$crumbs[] = l(t('Catalog'), 'catalog');
$used_tids = array();
foreach ($terms as $term) {
if (!isset($parents[$term['tid']])) {
$parents[$term['tid']] = taxonomy_get_parents_all($term['tid']);
}
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);
}
}
}