I have a term view where I only want to show terms with depth 0. Is this possible with this module? Thanks.

Comments

joel_guesclin’s picture

I would also like an answer to this. I have discovered (obvious I suppose) that if you have a node type view, then only terms with nodes attached are displayed. However, you can choose a filter "Taxonomy: TermId (with depth)".
If you have a Term-type view, on the other hand, this filter is not available - which seems strange on the face of it.
Consequently whereas you could do this using a Node view (but of course only if there are nodes attached to the top terms which you don't necessarily want - this is my case), you can't with a Term view.

MBroberg’s picture

It seems to me that "Taxonomy: TermId (with depth)" allows a filter to select terms that are not actually attached to the node but are higher or lower in the tree. What I want is to actually show only terms with a specific depth, in my case depth of 2.

For example I have county, city, and park attached but only want to show the park name, yet be able to sort by the city or county.
If I had only attached the park name I should be able to use "Taxonomy: TermId (with depth)" to also show city and county, but that is not what I want, and I do need the other terms attached for other reasons.

Seems like this module gets close but not quite there yet.

xjm’s picture

Assigned: Unassigned » xjm

I'll look into this.

joel_guesclin’s picture

Rereading my post I'm not sure if it is clear. To take MBroberg's example and apply it to my use case, I would have Parks as nodes, county and city as taxonomy terms. This means that there are never any Parks (or indeed any other nodes) attached to County. So if, for example, I want to show a list of counties, this won't work in a Node View because they have no nodes attached.

mxt’s picture

Subscribing, I'm interested in too.

joel_guesclin’s picture

I managed to get this working in a very roundabout way using Semantic Views module to attribute classes to the different levels of the output, and then using CSS "display:none" to stop the class associated with the duplicated output from appearing. I don't know if this helps.

zship’s picture

It looks like the functionality's there, but the Views hook defined in lineage.views.inc doesn't define that filter. Should be easy enough to implement, so someone do it.

...Just kidding. I changed a few lines and verified that it's working for me. The new code is the 'filter' element under $tables['term_lineage']['depth']['filter'].

//lineage.views.inc:12
function lineage_views_data() {
  $tables['term_lineage'] = array(
    'table' => array(
      'group' => t('Taxonomy'),
      'join' => array(
        'node' => array(
          'left_table' => 'term_node',
          'left_field' => 'tid',
          'field' => 'tid',
        ),
        'term_data' => array(
          'left_field' => 'tid',
          'field' => 'tid',
        ),
      ),
    ),
    'lineage' => array(
      'title' => t("Hierarchy"),
      'field' => array(
        'handler' => 'lineage_handler_field',
        'click sortable' => TRUE,
        'help' => t('Taxonomy lineage hierarchy'),
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    ),
    'depth' => array(
      'title' => t("Depth"),
      'field' => array(
        'handler' => 'views_handler_field',
        'help' => t('Taxonomy lineage depth'),
      ),
	  'filter' => array(
		  'handler' => 'views_handler_filter_numeric'
	  ),
    ),
  );

  return $tables;
}
xjm’s picture

#7: Wanna roll that into a patch?

zship’s picture

I'm on a bit of a tight deadline for the project that required this change, and I'm afraid I don't have experience creating patches. Looked into the documentation on how to do it, and once I have time to install git or learn the old way, I'll add a patch here.

gotcha41’s picture

subscribing