I need to implement a way to show only the taxonomy that is controlling access to a node in the 'links' area of the node. Currently I can show all associated terms, but that is too much and too confusing, not being specific to access control. I'm going to be looking into it more, but any help in letting me know how to list the taxonomy that tac_lite it using would be appreciated!

This is what I know so far, this code below from theme.inc will pull all associated taxonomy terms for the node and theme it. Beautiful - we should do this from tac_lite. But we'll need a taxonomy_link function specifically for tac_lite.

  if (module_exist('taxonomy')) {
    $terms = taxonomy_link('taxonomy terms', $node);
  }

  if (count($terms)) {
    $output .= ' <small>('. theme('links', $terms) .')</small><br />';
  }

Here is the current taxomomy_link function, taken from http://api.drupal.org/api/4.7/function/taxonomy_link

function taxonomy_link($type, $node = NULL) {
  if ($type == 'taxonomy terms' && $node != NULL) {
    $links = array();
    if (array_key_exists('taxonomy', $node)) {
      foreach ($node->taxonomy as $term) {
        $links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
      }
    }
    return $links;
  }
}

So, anyone know how to revise that function to spit out only terms used for tac_lite? yogadex? :)

Thank you!!!!
Jamie.

Comments

JamieR’s picture

Is this where we get the taxonomy terms controlling access to the node?

function _tac_lite_get_terms_by_nid($nid) {
  $tids = array();
  $terms = taxonomy_node_get_terms($nid);

  // terms is now an array of objects.  We convert to a simple array of tids
  foreach ($terms as $term) {
	$tids[$term->tid] = $term->tid;
  }
  return $tids;
}

Perhaps I'm getting closer...

Dave Cohen’s picture

Priority: Normal » Minor
Status: Active » Closed (won't fix)

Here's a snippet from the latest tac_lite that may fit your needs. You're going to have to experiment...

And BTW, this is not really relevant to tac_lite, as it has nothing to do with the links shown with each node. You're probably going to have to modify your theme to do what you want.

  // all terms from all vocabs
  $all_tids = _tac_lite_get_terms($node);
  // just the vocabs we're interested in
  $vids = variable_get('tac_lite_categories', null);
  // now find just the terms we're interested in.
  $tids = array();
  if (count($all_tids) && count($vids)) {
	$result = db_query("SELECT DISTINCT td.tid FROM {term_data} td LEFT JOIN {term_hierarchy} th on td.tid = th.parent WHERE td.vid IN (%s) AND td.tid IN (%s) AND th.tid IS NULL",
					   implode(',', $vids),
					   implode(',', $all_tids));
	while ($term = db_fetch_object($result)) {
	  $tids[] = $term->tid;
	}
  }