I am not sure how I would properly and clearly explain this question. What I am looking for in general is a tagcloud that is sensitive to context. So it will only list the tags that are relevant to the content that you are looking.

Let's say you have a repository of links all of which can be tagged freely. On the highest level (the entry archive page) you will have a tagcloud that shows all the tags that exists. Once you will click on one of those tags, it will list all the links that are tagged with that specific keyword. However, the tagcloud will now not show ALL tags, but just an aggregation of all tags within the context of the tag on which you have already filtered. Quite an abstract explanation. Let me try to give an example. Let's say you have 5 links, which are tagged comma separated:

Link1: tag1, tag3
Link2: tag1
Link3: tag2, tag5
Link4: tag3, tag5
Link5: tag4, tag5

So, on the highest level, you will have a tagcloud that shows all tags: tag1, tag2 ... tag5. Let's say you click on tag3. On the archive page of tag3, you will only see tags that are relevant to that tag, in this case: tag1, tag3, tag5 (see Link1 and Link4, both are tagged with tag3, but have tag4 and 5 additionally)

I hope I could make it a bit clear. Any clues on how to accomplish this with Drupal?


What I think you are saying you want to do is this:

  1. Grab all content that is tagged with a certain term, then
  2. List in a block all taxonomy terms from that content

And if so, it's pretty straightforward to loop through a list of node and aggregate and each taxonomy term that is attached to each node, and then stylize a block of those terms, eg,

$nids= // execution results of a view or other sql that filters on a term;

foreach ($nids as $nid) {
   foreach ($node->taxonomy as $t) {

which will (if my off the top of the cuff php code is accurate ;-) produce an array $found that is a list of terms that can be styled however you wanted in a variable or block, most simply like:

 foreach ($found as $tid => $name) {
    $content.=l($name,'taxonomy/term/' . $tid) . ' ';
 return $content;

You can probably do all of this in a View itself with some funky templating, too, if you didn't want to create a module and/or theme preprocess function.

| improve this answer | |

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.