0

I use the Views version of the taxonomy listing page. For performance reasons, I can't use a depth of 1 on the 'Taxonomy Term (depth)' contextual filter.

Unfortunately, for one taxonomy, ALL terms are a child of this one set of six terms (think Publication / Issues of a magazine). Is there a way I can, in my menu, link to the parent terms, yet have that listing page show only the nodes from the most recent child?

Otherwise, is there a way, in that View, to have an increased depth (1 vs 0) ONLY if there are no nodes for the particular term?

0

So I figured this out, wasn't too complicated at all. Use hook_menu. I didn't write my SQL using the Drupal DB API, but it works:

function ain_custom_menu() {


 $items = array();

  // Item1
  $items['taxonomy/term/218489'] = array(
    'title' => 'Title1',
    'page callback' => 'MYMODULE_find_newsletter',
    'page arguments' => array("218489"),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );

  // Item2
  $items['taxonomy/term/218500'] = array(
    'title' => 'Title2',
    'page callback' => 'MYMODULE_find_newsletter',
    'page arguments' => array("218500"),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;

}

function MYMODULE_find_newsletter($mytid) {
  $tid = db_query('SELECT max(tid) AS tid FROM taxonomy_term_hierarchy t1 
    JOIN field_data_field_pubissue t2 ON t1.tid = t2.field_pubissue_tid
    JOIN node t3 ON t2.entity_id = t3.nid
    WHERE t1.parent = '.$mytid.' AND t3.status = 1')->fetchField();
  $latest = is_numeric($tid) ? 'taxonomy/term/' . $tid : '<front>';
  drupal_goto($latest);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.