You are here

function _taxonomy_menu_page in Taxonomy menu 6

Same name and namespace in other branches
  1. 5 taxonomy_menu.inc \_taxonomy_menu_page()

Page callback that renders a node listing for the selected term.

1 string reference to '_taxonomy_menu_page'
_taxonomy_menu_menu in ./taxonomy_menu.inc
Implementation of hook_menu().

File

./taxonomy_menu.inc, line 254
@author Jonathan Chaffer <jchaffer@structureinteractive.com> @author Bruno Massa <http://drupal.org/user/67164> taxonomy_menu.inc It Generates menu links for all taxonomy terms

Code

function _taxonomy_menu_page() {

  // Check if the Vocabulary ID is set
  if ($vid = arg(1)) {

    // Depending on what Output technique is used,
    // show the nodes' list
    if (variable_get('taxonomy_menu_show_' . $vid, TAXONOMY_MENU_NONE) == TAXONOMY_MENU_NORMAL) {
      if ($tid = arg(2)) {
        $tid = explode('/', $_GET['q']);
        $tid = db_escape_string(array_pop($tid));

        // Add the RSS feed
        $feed = url('taxonomy/term/' . $tid . '/' . (variable_get('taxonomy_menu_display_descendants', 1) ? 'all' : 0) . '/feed');
        drupal_add_feed($feed);

        // Get the nodes
        $result = taxonomy_select_nodes(array(
          $tid,
        ), 'or', variable_get('taxonomy_menu_display_descendants', 1) ? 'all' : 0);
      }
      else {

        // If no arg(2), we're looking at just the vid. If
        // display_descendants is on, grab all terms regardless
        // of depth. If off, grab depth 0 terms.
        $tree = taxonomy_get_tree($vid);
        $descendants = variable_get('taxonomy_menu_display_descendants', 1);
        foreach ($tree as $term) {
          if ($descendants or $term->depth == 0) {
            $tids[] = $term->tid;
          }
        }

        // The requested terms have already been determined,
        // so don't request descendants here.
        $result = taxonomy_select_nodes($tids, 'or', 0);
      }

      // Render the selected nodes
      $output = taxonomy_render_nodes($result);
    }
    elseif (variable_get('taxonomy_menu_show_' . $vid, TAXONOMY_MENU_NONE) == TAXONOMY_MENU_VIEW) {

      // Get the last page argument
      $tid = explode('/', $_GET['q']);
      $tid = db_escape_string(array_pop($tid));
      $arguments[] = $vid;

      // Only add the Term ID if its not the Vocabulary ID
      if ($vid != $tid) {
        $arguments[] = $tid;
      }

      // Embed the views output into the page
      $view = views_get_view(variable_get('taxonomy_menu_show_views_' . $vid, ''));
      $output = $view
        ->execute_display('embed', $arguments);
    }
    elseif (variable_get('taxonomy_menu_show_' . $vid, TAXONOMY_MENU_NONE) == TAXONOMY_MENU_DEFAULT_TAX) {
    }
  }

  // If no content found, return a "error" message
  return empty($output) ? t('No content for this category.') : $output;
}