function uc_catalog_block in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_catalog/uc_catalog.module \uc_catalog_block()
Displays a menu for navigating the "Product Catalog"
File
- uc_catalog/
uc_catalog.module, line 334 - Übercart Catalog module.
Code
function uc_catalog_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0] = array(
'info' => variable_get('uc_catalog_name', t('Catalog')),
'status' => 1,
);
return $blocks;
case 'view':
$block = array();
if (user_access('view catalog')) {
switch ($delta) {
case 0:
// Get the vocabulary tree information.
$vid = variable_get('uc_catalog_vid', 0);
$tree = taxonomy_get_tree($vid);
// Then convert it into an actual tree structure.
$seq = 0;
$menu_tree = new uc_treeNode();
$level = array();
$curr_depth = -1;
foreach ($tree as $knot) {
$seq++;
$knot->sequence = $seq;
$knothole = new uc_treeNode($knot);
// Begin at the root of the tree and find the proper place.
$menu_tree
->add_child($knothole);
}
// Now, create a structured menu, separate from Drupal's menu.
$content .= theme("uc_catalog_block_start");
foreach ($menu_tree->children as $branch) {
list($inpath, $html) = _uc_catalog_navigation($branch);
$content .= $html;
}
$content .= theme("uc_catalog_block_end");
$subject = variable_get('uc_catalog_name', t('Catalog'));
if (variable_get('uc_catalog_block_title', true)) {
$subject = l($subject, 'catalog');
}
$block = array(
'subject' => $subject,
'content' => $content,
);
break;
}
}
return $block;
}
}