Hey all,

I figured the views que was the most logical place for this issue because taxonomy is part of drupal core as of 5x. If you know of a better place for this please let me know and I'll double post it.

Short and sweet:

I have 40-50 taxonomy terms in a list format, and many of those terms are interrelated using the "Related Terms" interface of taxonomy. So for example, "skiing" is related to "snowboarding." Ideally, I'd like to be able to make use of those "Related terms" in views. I.E. A filter option along the lines of "Taxonomy: Related Terms" and use Taxonomy term ID as an argument. So this would allow me to filter results by relevancy and provide it as a block view, a "See also" reference option. So if someone is viewing a node about skiing, they could see a block that says "See also: Snowboarding, sledding, ice skating...etc". This creates far more continuity within content.

How can this be done? Views surprisingly has no option for related terms within taxonomy, and I'm kind of at a loss of how I can provide this. It's especially useful as other filtration options, such as location proximity can be integrated for useful/relevant things nearby.

Thoughts on how to make this a reality?

Many thanks.

Comments

rc2020’s picture

Oh: I have googled contrib modules which might make this happen for me and came up blank. If someone else's searching skills are superior to mine and they know of one, please by all means share!

Thanks again.

rc2020’s picture

Im going to double post this in another que because you guys are so swamped with requests. If you have some time to look at this, great, if not I'll see who else is available, to say that you guys have your hands full is the understatement of the century...

merlinofchaos’s picture

Title: Taxonomy Related Terms in Views » Add "Related term" relationship for term_data
Category: support » feature

Ok, you can ALMOST do this with Views, using some PHP code in a default argument in order to extract the terms you need.

However, there is a problem, and that is that there's no relationship to related terms.

Such a thing would be almost trivial to add as a patch, you could probably almost cut & paste the parent term relationship. With that relationship this is actually possible by using a 'Term' view, a taxonomy: term ID argument, some PHP code to extract the terms from the current node and reformat them to X+Y+Z, then the related terms relationship and displaying the new term.

gunzip’s picture

subscribe

deltab’s picture

merlinofchaos, can you elaborate a little more for a newbie? I am trying to get a block like this going (i can use this module, http://drupal.org/project/related_terms but need terms ordered by vocabulary), and need more explicit hints to get it done.

jvieille’s picture

Subscribe.
I use D6, but I think this will be addressed for both versions.

I don't really see the interest of the "Related term" in vocabularies if one cannot use this relation in Views.
The Drupal Designers had a great idea in mind, but it was not much taken benefit of.

Taxonomy is a great Drupal feature, Views can leverage it.

KoCo’s picture

(also using D6)
I used the following in a complex bit of code, which matches a user role to a parent term,
then gets all the children, and the related terms from each child, usually resorting under another parent term within the same vocab.
The providing an 'or' list to views as argument.

// $pid is the parent term id 
 $vargs = array();
 $termc = taxonomy_get_children($pid, $vid = 7, $key = 'tid');
 foreach ($termc as $tid => $term) {
  $vargs[] = $tid;
  $termr = taxonomy_get_related($tid, $key = 'tid');
  foreach ($termr as $rid => $term) {
   $vargs[] = $rid;
  }
 }
$vargs = array_unique($vargs);
return implode("+", $vargs);

The problem off course, how to get this working when using filters.
Does unlocking the operator helps getting views to work with the argument provided by the filter?
If it can use the $_GET to run the little sequence above, then I can start using related terms in filters.

thx

jvieille’s picture

Is nobody really interested in this feature?

gagarine’s picture

Filter and argument also don't provide related term functionality: #604624: Showing the nodes under a taxonomy term AND under the related terms

esmerel’s picture

Status: Active » Closed (won't fix)

No commits are being made to the 5.x branch at this point.