Taxonomy: a top-level point of view?

Can I create a view to see only top-level words in the dictionary? I cannot get it to stop listing all the terms using the dictionary ID argument. I just want to see top-level parents.

+4
source share
3 answers

This blog post tells how to do this: http://www.raisedeyebrow.com/2011/01/show-only-top-level-terms-in-a-term-type-drupal-view/

Essentially, you need to add a relation to the term parent. Then add a filter for the term name and select null using the parent relation. Effectively shows only those terms that do not have a parent.

+4
source

You can add a Taxonomy: Term ID filter and manually select which conditions to show (it can be tedious if you have a large vocabulary).

OR

You can add a template file for a field in your view to determine what conditions should be displayed. For example, in your opinion, you can simply add the Taxonomy: Term ID field. Copy views-view-field.tpl.php to the theme folder from the catalog of view modules (by topic). Go to "Topic Information" in the "Basic Settings" section and find the appropriate name for the template and create a new file using this name. For example, mine was views-view-field--tax--tid.tpl.php .

To only show the term term names that are the top level of the dictionary, use the following (or similar) in the new template file:

 <?php if (count(taxonomy_get_parents($output, $key = 'tid')) == 0) { $term = taxonomy_get_term($output, $reset = FALSE); print $term->name; } ?> 
+1
source

Yes, it's possible, but not necessarily with view.Bowow is one way to get top-level words in a dictionary.

 $tree = taxonomy_get_tree($vocabulary_id, 0, -1, 1); 

taxonomy_get_tree returns a flat array of terms, so you can use it while printing. A.

Regards, Chintan.

0
source

All Articles