You are here

function theme_taxonomy_list_directory in Taxonomy List 7

Same name and namespace in other branches
  1. 5.2 taxonomy_list.module \theme_taxonomy_list_directory()
  2. 6.2 taxonomy_list.module \theme_taxonomy_list_directory()

Theme a directory list.

Parameters

$terms: the enhanced term tree.

$cells_per_row: the number of cells per row to display. -- not used for directory.

$list_mode: indicates how to show the hierarchy.

Return value

the themed list to be displayed.

File

./taxonomy_list.module, line 584
List all terms in a vocabulary.

Code

function theme_taxonomy_list_directory($variables) {

  // Allow collapsible form elements.
  drupal_add_library('system', 'drupal.collapse');
  $terms = $variables['terms'];
  $cells_per_row = $variables['cells'];
  $list_mode = $variables['title'];
  $hide_empty = variable_get('taxonomy_list_noshow', FALSE);
  $view_mode = 'teaser';
  $output = '<div class="taxonomy-list-directory">';
  foreach ($terms as $tid => $term) {
    if (!$term->depth) {

      // Only do top level terms here.
      $data = '<div class="taxonomy-list-directory-description">' . $term->desc . '</div>';
      $nodes = taxonomy_list_select_nodes(array(
        $tid,
      ));
      foreach ($nodes as $node_found) {

        // @TODO: Option for unpublished?
        if ($node_found->status == 1) {
          $node = node_load($node_found->nid);
          $data .= theme('taxonomy_list_directory_node', array(
            'node' => $node,
            'term' => $term,
          ));
        }
      }

      // If there were no nodes, skip the whole thing.
      if ($term->node_count == 0 && $hide_empty) {
        continue;
      }
      if ($term->children) {
        $data .= _taxonomy_list_directory_children($term->children, $terms);
      }
      $fieldset = array(
        'element' => array(
          '#title' => check_plain($term->name),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
          '#value' => $data,
          '#children' => '<div>',
          '#attributes' => array(
            'class' => array(
              'collapsible',
              'collapsed',
            ),
          ),
        ),
      );
      $output .= theme('fieldset', $fieldset);
    }
  }
  return $output . '</div>';
}