2

I have following taxonomy structure

parent-A
    subterm-1
        sub-subterm-a
        sub-subterm-b
    subterm-2

how can I show contents of both the sub-subterm (a and b) when i select/click subterm-1 ; and contents from subterm-1 (sub-subterm a+b) and from subterm-2 when I select parent-A using views - block display

3
  • What exactly you would like to achieve? Maybe you could use panels and views to do this, maybe you could tag with multiple tags so that parent level content is also tagged with lower level tags?
    – LLub
    Dec 26, 2012 at 20:39
  • I want to display the content of child-term as teaser under that child's parent-term
    – user137
    Dec 27, 2012 at 7:23
  • have you check this drupal.stackexchange.com/questions/70851/…
    – Naveen
    Aug 6, 2016 at 5:34

1 Answer 1

0

This may not be the most standard way of achieving it but it may help in your case. Just try the following code by replacing 24 with a $termid that exists in your case. And see if this gets your work done.

    //to get the children of a taxonomy term
    //lets take 24 for example 

      $terms = taxonomy_get_children('24');

      //to get the nodes associated with a termid

     foreach ($terms as $term) {
         $termnodes = taxonomy_select_nodes($term->tid);

         foreach ($termnodes as $termnode) {
              $node = node_load($termnode);
              $node_output = node_view($node);
              print render($node_output, $view_mode = 'teaser'));
        }
  }
4
  • I have exactly this problem drupal.stackexchange.com/questions/28062/…
    – user137
    Dec 27, 2012 at 8:22
  • Do you want to display the nodes in a block or a page ? and if page, is it a normal page or taxonomy-term's page ? Dec 27, 2012 at 8:39
  • I want to show nodes in block
    – user137
    Dec 27, 2012 at 8:47
  • I have updated the answer, please check it and try once. If this is not exactly what you want, then the modifications can be done according to your requirements. Dec 27, 2012 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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