function taxonomy_list_show in Taxonomy List 5
Same name and namespace in other branches
- 5.2 taxonomy_list.module \taxonomy_list_show()
- 6.2 taxonomy_list.module \taxonomy_list_show()
- 6 taxonomy_list.module \taxonomy_list_show()
- 7 taxonomy_list.module \taxonomy_list_show()
Show the category list
1 call to taxonomy_list_show()
- taxonomy_list_block in ./
taxonomy_list.module - Implementation of hook_block().
1 string reference to 'taxonomy_list_show'
- taxonomy_list_menu in ./
taxonomy_list.module - Implementation of hook_menu().
File
- ./
taxonomy_list.module, line 60 - List the category specified in the URL
Code
function taxonomy_list_show($str_vids, $max_depth = 'all', $op = NULL, $columns = NULL, $type = NULL) {
$breadcrumbs = drupal_get_breadcrumb();
if ($str_vids == 'all') {
$vocs = taxonomy_get_vocabularies();
$vids = array();
foreach ($vocs as $vid => $vocab) {
$vids[] = $vid;
}
}
else {
if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_vids)) {
// The '+' character in a query string may be parsed as ' '.
$vids = preg_split('/[+ ]/', $str_vids);
}
else {
if (preg_match('/^[0-9]+$/', $str_vids)) {
$vids = array(
$str_vids,
);
}
}
}
if (count($vids) <= 0) {
drupal_not_found();
return;
}
// Do we want to list the nodes?
if ($op == 'list') {
return taxonomy_list_nodes_render($vids, $max_depth, $type);
}
$controls = array(
'show_image' => variable_get('taxonomy_list_show_image', 1),
'cells_per_row' => $columns ? $columns : variable_get('taxonomy_list_cell_per_row', 2),
'count_type' => variable_get('taxonomy_list_count', 'none'),
'no_show' => variable_get('taxonomy_list_noshow', FALSE),
'edit_link' => $op == 'block' ? FALSE : variable_get('taxonomy_list_edit_link', FALSE),
'search_link' => $op == 'block' ? FALSE : variable_get('taxonomy_list_search_link', FALSE),
'rss_link' => variable_get('taxonomy_list_rss_link', FALSE),
'image_link' => variable_get('taxonomy_list_image_link', 'term'),
'destination' => urldecode(drupal_get_destination()),
'taxonomy_image' => module_exists('taxonomy_image'),
'list_mode' => variable_get('taxonomy_list_list_mode', 0),
'max_depth' => $max_depth == 'all' ? 9999999 : $max_depth,
'related' => variable_get('taxonomy_list_related', FALSE),
'synonyms' => variable_get('taxonomy_list_synonyms', FALSE),
'block' => $op == 'block',
'show_parents' => variable_get('taxonomy_list_show_parents', FALSE),
'kids' => variable_get('taxonomy_list_show_children', FALSE) ? '/all' : NULL,
'ntf_avail' => module_exists('node_type_filter'),
);
if ($controls['cells_per_row'] > 0) {
$controls['cell_width'] = floor(100 / $controls['cells_per_row']);
}
else {
$controls['cell_width'] = 100;
}
$vocab_titles = array();
$total_terms = 0;
$output = '<div class="taxonomy-list">';
foreach ($vids as $vid) {
$vocab = taxonomy_get_vocabulary($vid);
$vocab_titles[] = $vocab->name;
switch ($controls['list_mode']) {
case 0:
// Hierarchical. Only get first level, because _get_table will do children.
$terms = taxonomy_get_tree($vid, 0, -1, 1);
break;
case 1:
// Flat. Get all terms.
$terms = taxonomy_get_tree($vid, 0, -1, $controls['max_depth']);
break;
}
$c = count($terms);
if ($c <= 0) {
// This vocab has no term, skip.
continue;
}
$total_terms += $c;
$output .= theme('taxonomy_list_vocabulary', $vocab, variable_get('taxonomy_list_types', FALSE), count($vids) > 1);
$output .= _taxonomy_list_get_table($terms, $vocab, $controls, 1);
}
if ($op != 'block') {
$titles = implode(variable_get('taxonomy_list_title_separator', ' & '), $vocab_titles);
drupal_set_title($titles);
// $breadcrumbs[] = l(t('Terms for !vids', array('!vids' => $titles)), 'taxonomy/vocabulary/'. $str_vids);
// drupal_set_breadcrumb($breadcrumbs);
}
$output .= '</div>';
// class="taxonomy-list"
if ($total_terms == 0) {
drupal_not_found();
return;
}
if ($op != 'block') {
$output .= theme('taxonomy_list_admin_links', $vids);
}
return $output;
}