This is a little complicated to explain, here goes... I have a taxonomy that has duplicate term names with different parents; for example

diseases (tid=39) has child term ears (tid=117) and
symptoms (tid=43) has child term ears (tid=129)

My page view has the URL articles/%/% and two contextual filters using the same taxonomy; the first one us Parent term and the second one uses Term id.

Both use provide default value "taxonomy term ID from URL" and validator "Taxonomy term" with term name converted to Term ID.

This works for most parent/child terms, except when I have the same term name under two parents. Looking at the generated SQL, the WHERE clause for articles/symptoms/ears is using

WHERE (( (taxonomy_term_data_field_data_field_blog_category__taxonomy_term_hierarchy.parent = '43' ) AND (taxonomy_term_data_field_data_field_blog_category.tid = '129' ) )

But for articles/diseases/ears, it is using

WHERE (( (taxonomy_term_data_field_data_field_blog_category__taxonomy_term_hierarchy.parent = '39' ) AND (taxonomy_term_data_field_data_field_blog_category.tid = '129' ) )

As you can see, both are using tid 129 for the child term. Apparently it is finding the first match for the term name. I think it would work if the second part of the query were expanded to match all child terms, i.e.

(AND (taxonomy_term_data_field_data_field_blog_category.tid = '117' ) OR AND (taxonomy_term_data_field_data_field_blog_category.tid = '129' )

Comments

pglatz created an issue. See original summary.

geekygnr’s picture

I can confirm this issue, I just ran into this issue today.

As an interim solution I am using the tid's for the children in the address bar.

gonzalovp’s picture

Sorry but i'm having the same problem here, any update on this issue. Could you find a way to solve the problem using taxonomy term name and not the ID ?

riddhi.addweb’s picture

Issue summary: View changes
christian.rolf’s picture

Hi, same issue here:( Is there anybody who have solved this?

soyjaz’s picture

Hello,

I have had the same issue for a different use case : duplicate name of Cities in the same vocabulary.
My URLs have the pattern : city/[field_departement_nom]/[name]
[field_departement_nom] is a custom field added that represents the administrative area, this value cannot be duplicated, but it happens that some [name] (term names) of cities are identical.
I solved this by altering the query with hook_views_query_alter.
Below is the code I wrote in my .module of my custom module :

function yourmodule_views_query_alter(&$view, &$query){
if($view->name == 'your_view_name'){
                //1
		$w = $query->where[0]['conditions'];		
		$dep = $w[0]['value'];
		$city= $w[1]['value'];

                //2
		$q = 
                db_query('select tid from taxonomy_term_data a 
		inner join field_data_field_departement_nom b on a.tid = b.entity_id 
		where b.field_departement_nom_value = :d 
                and name = :v',array(':d' => $dep, ':v' => $city))->fetchObject();

                //3
		$query->where[0]['conditions'][1]['value'][':field_data_field_chauffeur_villes_field_chauffeur_villes_tid'] = $q->tid;
		return $query;
	}
}

//1 : to get the list of the "where" conditions, use dpm($query->where) or print_r if you don't have devel so you get the appropriate index of the condition you wish to alter

//2 : the tables i named "a" and "b" respectively contains :
a : tid & name ___ b : entity_id & field_departement_nom
i'm doing a SQL joint to find the correct tid in function of the name and the field_departement_nom.
Note that my code will only work if you specify in your Contextual Filter a Validation Criteria that has for Filter value type the Term name. It'll generate a line like this :
:field_data_field_chauffeur_villes_field_chauffeur_villes_tid = Paris
but it is rewritten with the tid afterwards.

//3 : replacement of the current value by the appropriate one : the correct tid
----------
This isn't a direct answer to OP but can it explains the direction to follow to solve such problem.
With the display of the Views Query in the configuration page (activation of the display at /admin/structure/views/settings) look for the condition that you want to rewrite, create & execute the proper SQL Query then alter the results.

Hope it helps.

koosvdkolk’s picture

I got this to work in the Views GUI by

  1. adding a Relationship 'Content: Taxonomy terms on node';
  2. in Contextual filters, '(term) Taxonomy term: Name' became available
  3. in this filter, I checked 'Specify validation criteria' and then selected 'Taxonomy term';
  4. next I selected the Vocabularies of choice;
  5. finally I selected 'Term name' under 'Filter value type'.