1

I've a list of taxonomy terms with related subs as follows:

Father 1

  • child 1.1
  • child 1.2
  • child 1.n

Father 2

  • child 2.1
  • child 2.2
  • child 2.n

Father 3

  • child 3.1
  • child 3.2
  • child 3.n

and so on.

I need to put a list of the father followed by the first 5 child elements in a block and put it into homepage.

Now the point is, that after lots of trying, I didn't find a solution about how I can do this.

The only thing that I managed was the selective display of the fathers, but I didn't reach the child in any way. I don't reach the father through a node, or his own term page, because I only need the taxonomy tree iterated in a block containing a list of unformatted columns.

I have already themed all but I'm still not capable of displaying the childs under the father term.

For short, here is a representation of what I'm looking for: This is a representation of my need

I'm going out of my head because of this, so any help will be greatly appreciated!

1
  • 1
    Note about my edit just now: I adapted (removed) some of the wordings in your question, to ensure it matches the site standards. This to avoid it gets flagged to moderators (which might even cause the question to be removed). Just trying to "help", ok? – Pierre.Vriens Jul 15 '15 at 21:43
1

If you didn't find better solution you may create one view that will display parent term name and parent tid and second view that will display four children with a contextual filter by parent tid. And using template_preprocess_views_view_field insert view with terms children in the view with parents.

/**
 * Implements hook_preprocess_views_view_field().
 */
 function mymodule_preprocess_views_view_field(&$vars) {
   switch ($vars['view']->name) {
     case 'terms_parents':
       if ($vars['field']->options['id'] == 'tid') {
         $vars['output'] = views_embed_view('children_view', 'display', array($vars['output']));
       }
       break;
   }
}
1
  • 1
    You just hit the point. I tried this yesterday but with no result. maybe because of tiredness. Tried this approach today and achieved result together with Views field view module in substitution of your custom code – andsigno82 Jul 16 '15 at 10:01
0

Consider adding appropriate "relationships" to your view (think of a "join" in SQL).

If that doesn't help, consider enhancing your question by adding a screebprint of your current view setup (wher eyou can see fields, relatationships, etc).

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.