function uc_catalog_get_page in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_catalog/uc_catalog.module \uc_catalog_get_page()
Loads catalog information for display.
Retrieves image, product, and subcategory information for the current term id.
Parameters
$tid: Taxonomy term id.
Return value
A catalog object containing all the information needed to display a catalog page.
1 call to uc_catalog_get_page()
- theme_uc_catalog_browse in uc_catalog/
uc_catalog.pages.inc - Display a formatted catalog page.
File
- uc_catalog/
uc_catalog.module, line 644 - Ubercart Catalog module.
Code
function uc_catalog_get_page($tid) {
$catalog = new stdClass();
$vid = variable_get('uc_catalog_vid', 0);
if ($tid) {
$term = taxonomy_get_term($tid);
$name = $term->name;
$description = $term->description;
}
else {
$tid = 0;
$name = variable_get('uc_catalog_name', t('Catalog'));
$description = variable_get('uc_catalog_description', '');
}
$catalog->tid = $tid;
$catalog->vid = $vid;
$catalog->name = $name;
$catalog->description = $description;
$catalog->children = array();
if ($file = uc_catalog_image_load($catalog->tid)) {
$info = image_get_info($file->filepath);
$catalog->image = $info;
$catalog->image['filepath'] = $file->filepath;
}
$types = uc_product_types();
$links = array();
$child_list = array();
$children = taxonomy_get_children($tid, $vid);
foreach ($children as $child) {
$n = 0;
foreach ($types as $type) {
$n += taxonomy_term_count_nodes($child->tid, $type);
}
$child->nodes = $n;
// Display child category's image.
if ($file = uc_catalog_image_load($child->tid)) {
$info = image_get_info($file->filepath);
$child->image = $info;
$child->image['filepath'] = $file->filepath;
}
// Display list of child category's children categories.
// If more than $max_gc_display, show "More..." link to child.
$grandchildren_list = taxonomy_get_children($child->tid, $vid);
$child->children = $grandchildren_list;
$catalog->children[] = $child;
}
//$node_resource = taxonomy_select_nodes(array($tid));
return $catalog;
}