function ctools_term_list_content_type_render in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 plugins/content_types/term_context/term_list.inc \ctools_term_list_content_type_render()
File
- plugins/
content_types/ term_context/ term_list.inc, line 17
Code
function ctools_term_list_content_type_render($subtype, $conf, $panel_args, $context) {
$term = isset($context->data) ? drupal_clone($context->data) : NULL;
$block = new stdClass();
$block->module = 'term-list';
$options = ctools_admin_term_list_options();
if ($term) {
$block->subject = $options[$conf['type']];
$block->delta = $conf['type'];
switch ($conf['type']) {
case 'related':
$terms = taxonomy_get_related($term->tid);
break;
case 'child':
default:
$terms = taxonomy_get_children($term->tid);
break;
case 'top':
$terms = taxonomy_get_children(0, $term->vid);
break;
case 'sibling':
$parent = db_result(db_query("SELECT parent FROM {term_hierarchy} WHERE tid = %d", $term->tid));
$terms = taxonomy_get_children($parent, $term->vid);
// Remove the term that started this.
unset($terms[$term->tid]);
break;
case 'synonyms':
$terms = taxonomy_get_synonyms($term->tid);
break;
}
if ($terms) {
foreach ($terms as $related) {
if (is_object($related)) {
$items[] = l($related->name, taxonomy_term_path($related), array(
'rel' => 'tag',
'title' => strip_tags($related->description),
));
}
else {
$items[] = check_plain($related);
}
}
$block->content = theme('item_list', $items, NULL, $conf['list_type']);
}
}
else {
$block->content = t('Term description goes here.');
$block->delta = 'unknown';
}
return $block;
}