You are here

function panels_content_term_list in Panels 6.2

Same name and namespace in other branches
  1. 5.2 content_types/term_list.inc \panels_content_term_list()
1 string reference to 'panels_content_term_list'
panels_term_list_panels_content_types in content_types/term_list.inc
Callback function to supply a list of content types.

File

content_types/term_list.inc, line 20

Code

function panels_content_term_list($subtype, $conf, $panel_args, $context) {
  $term = isset($context->data) ? drupal_clone($context->data) : NULL;
  $block = new stdClass();
  $block->module = 'term-list';
  $options = panels_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) {
        $items[$related->tid] = l($related->name, taxonomy_term_path($related), array(
          'rel' => 'tag',
          'title' => strip_tags($related->description),
        ));
      }
      $block->content = theme('item_list', $items, NULL, $conf['list_type']);
    }
  }
  else {
    $block->content = t('Term description goes here.');
    $block->delta = 'unknown';
  }
  return $block;
}