Is this not possible as it was in Drupal 7 to convert taxonomy terms in the URL to their ID?
See this post on Stackexchange: http://drupal.stackexchange.com/questions/174251/taxonomy-term-name-as-c...
I try "Content: Has taxonomy term ID" and set the validator to "term name", but when I try to put in "term name" as a validator and use the term name in the preview box, it looks like it's trying to use the 'tid' field of the taxonomy_index table with the textual value of the term:
WHERE (( (taxonomy_index.tid = 'Discussion') )AND
When I try to use the TID, I just get a 'no query was run' message and nothing is returned.
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedtoddmbloom created an issue. See original summary.
Comment #2
webiator GmbH CreditAttribution: webiator GmbH commentedHello toddmbloom,
I also have been looking for this functionality for quite some time now. Ended up creating a reference to taxonomy terms referenced by content and then adding a contextual filter "term name".
If you do that then the validator will work. However you cannot have term names with slashes "/" or any other special characters.
Hope that helps,
Regards
/B
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedAh ha, this was great.
For the record, creating a relationship with "Taxonomy terms on node" and configuring it to pull from the taxonomy you want to filter on from the URL will allow you to create a contextual filter using the term relationship for Taxonomy term: Name.
Comment #4
webiator GmbH CreditAttribution: webiator GmbH commentedOnly problem is that this does not work with term names which consist of more than letters and spaces.
Example:
A term name like "Management / Consulting" would not work because views would need "management-/-consulting" as contextual filter to map correctly ... :/
Any ideas on this one?
Comment #5
BerdirConsider generating aliases for your terms instead and work with the ID's internally. Will require custom code but not too much.
Comment #6
webiator GmbH CreditAttribution: webiator GmbH commented@Berdir:
I tried that already and this would mean that I have to use the core taxonomy view. Since pathauto cannot generate taxonomy term aliases if its pattern equals a view path.
Or am I missunderstanding something?
Comment #7
BerdirAs I said, you can use your own code to create aliases, the API is not that complicated to use:
\Drupal::service('path.alias_storage')->save($source, $alias);
You could also look into page_manager. It has the advantage that you can have variants that apply to just to terms of a specific vocabulary and have a different view/blocks for that.
Comment #8
OlafskiFor curiosity: Does anybody know why the Filter value type "Term name converted to term ID" option was removed in Views 8? It was really helpful for site builders.
Comment #9
calefilm CreditAttribution: calefilm commentedFor anyone running into the same problem I had... I kept searching through the Titles in Contextual Filters, lokoing for "Taxonomy Name" ... Just as "Taxonomy Term ID" is labeled correctly etc.... Instead, search for "Name" and you will find what you're looking for.
Comment #10
keithm CreditAttribution: keithm commented@calefilm this was very helpful.
Also see https://drupal.stackexchange.com/a/201215/2272
Comment #11
brianwagner CreditAttribution: brianwagner commented@calefilm is right on. Search for 'Name' to get taxonomy term name. Because it doesn't show up when you search for 'taxonomy'.
Comment #12
yuseferi CreditAttribution: yuseferi commentedUse https://www.drupal.org/project/views_taxonomy_term_name_depth module, it works correctly and let you filter (contextual filter) result according to term name.
Comment #13
iyyappan.govind@zhilevan,I have installed views_taxonomy_term_name_depth module but I can not see the that field in taxonomy term view.
Please help me
Thanks
Comment #14
rayorg CreditAttribution: rayorg as a volunteer commented"views_taxonomy_term_name_depth", or any other ones, does not work for me under any combination. That filter was very handy, why was it removed? Can it be added back?
Thanks!
Comment #15
sourabhutani CreditAttribution: sourabhutani commentedIs there anybody solved this issue for taxonomies names having spaces and dashes in name ? Drupal module
Views Taxonomy Term Name Depth
is not solving this.Comment #16
komejo CreditAttribution: komejo at ThinkShout commentedFor anyone else running into this issue, the simplest process at this time seems to be adding the relationship as mentioned in #3, then the https://www.drupal.org/project/views_taxonomy_term_name_depth plugin, and use the relationship with it. The plugin has a working implementation of the taxonomy term name from URL, even with dashes in the term.
Comment #17
seizethecarp CreditAttribution: seizethecarp as a volunteer commentedFor anyone else like me looking for how to make it work, I Gumped my way into my into success partly following: http://redcrackle.com/blog/adding-contextual-filter-view-drupal-8
I'm using Drupal 8 and Zircon. I'm brand new so I may use the wrong terms.
I wanted to make contextual images in "Panel first col 1" based on the Category of the page that someone is on.
What I did was go to Structure > Views > Carousel (the view that has the pictures in that block region) > Advanced > Add by Contextual Filters > Has taxonomy term ID > select in Provide default value: Taxonomy term ID from URL (which made no sense to me but whatever) > then I checked all three boxes: Load default filter from term page, Load default filter from node page, that's good for related taxonomy blocks, Limit terms by vocabulary. Then for Vocabularies I checked Categories.
PHEW! Finally!
Thanks to you all on here for pointing me in the right direction!
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedI am unable to make this work.
I have a content type called ‘Event’ with an entity reference to the Taxonomy Vocabulary ‘Production.’
I have created a view called ‘Book Tickets’ and I’d like a contextual filter that finds events based on a Procduction Taxonomy term.
So the url for the view should be /book-tickets/term-name e.g. /book-tickets/steptoe-and-son.
Is this possible? Reading previous posts and trialling different settings I have yet been able to get it to work, except when using the terms ID.
Comment #19
drupalnesia CreditAttribution: drupalnesia commented@TECreasey
When the filter value IS in the URL or a default is provided: Override title = {{ arguments.tid }}
{{ arguments.tid }} will convert Term Name to Term ID
This is D8 bug. The only solution right now is https://www.drupal.org/project/views_taxonomy_term_name_depth
Comment #20
cbfannin CreditAttribution: cbfannin commented@zhilevan recommendation in comment #12 worked for me! My relationship was already set up. My goal was to pull the first component from the URL to match up with a taxonomy term name as the contextual filter. The plugin allowed me to compare my path's component to the generated taxonomy term's name rather than the tid or Name as it was provided in my vocabulary list (i.e. the term "President's Office" became "presidents-office"). I set the contextual filter for WHEN THE FILTER VALUE IS NOT AVAILABLE Provide Default value > Type as Raw value from URL > Set my path component to 1 (in my case) and checked "use path alias". Now it works as expected. Thanks!
Comment #21
adamborecki CreditAttribution: adamborecki as a volunteer commented#12 also worked for me!
https://www.drupal.org/project/views_taxonomy_term_name_depth
That module solved the problem instantly, and the query works properly.
Comment #22
itchyeyeballs CreditAttribution: itchyeyeballs commentedThe limitation with this (https://www.drupal.org/project/views_taxonomy_term_name_depth) module seems to be that you can't specify which vocabulary to use, we want to use a vocabulary called "categories" to filter the view but there is a risk of rogue content showing up in if someone happens to enter a duplicate entry in the "tags" vocabulary when tagging their article.
Comment #23
dwwYeah, core is broken in this regard.
I just wrote https://www.drupal.org/project/views_taxonomy_term_name_into_id to restore the missing functionality.
Comment #24
imclean CreditAttribution: imclean commented@dww that looks very interesting. I wonder if a similar method could be used to reference existing taxonomy terms when creating content via REST. Or even creating new terms if they don't already exists. This feels like a generic problem in terms of taxonomy and entity references in general.
For example: #2771353: Support "auto-create" entity references by value (instead of by ID/UUID), just like tags are auto-created in the content creation UI
Comment #25
dww@imclean: "Similar method" -- maybe. Same module -- no way. ;) This is a tiny module to provide a single piece of missing core functionality. It's not meant to be, and never will become, "fix everything wrong with core's handling of term names".module. Sorry.
Meanwhile, more appropriate version and better title.
Comment #26
imclean CreditAttribution: imclean commented@dww Ha yes, I do understand that. I just keep coming across lack of entity reference functionality when not specifically using a widget to create the reference. Just talking conceptually here, this module is sensibly quite focussed on the one task
Comment #27
DiDebru#12 worked for me as well!
Comment #28
andyg5000@dww thank you for creating `views_taxonomy_term_name_into_id`. Until this point, I've been joining the taxonomy tables to the view and filtering down that way, but that approach has it's own problems.
I think people are used to this option in D7 and expect it to be available in D8. Is there any reason or push back that lead you to create a separate module vs a patch?
Comment #29
ardnet CreditAttribution: ardnet commentedHi all, solution #12 working for me, but is there any way to assign this to multiple terms?
Comment #30
dwwI had an urgent need, so I solved it in the quickest but most stable way I that I could share. In this case, it was a simple contrib module. I'm still in favor of a plan to fix all this in core itself. I don't have the time / bandwidth to spearhead that effort right now, find the most appropriate meta issue, update the summaries as appropriate, start rolling patch(es), etc. If someone else wants to run with that, I'll chip in when/where I can.
Thanks/sorry,
-Derek
Comment #32
Gung Wang CreditAttribution: Gung Wang commentedNone of above solutions works on my site.
There is a table named taxonomy_term_field_data_node_field_data
in this Views Query below. However, there is no such table in my Drupal 8 database.
Instead, the exact names of tables about taxonomy are:
Drupal Views Query:
I figured it out: all our faq_question contents are unpublished, so it always shows nothing in the View.
Comment #33
Pascal- CreditAttribution: Pascal- commentedI'm settings this to works as desgined, since the solution suggested in #2 and further explained in #3 worked for me.
There's also a workaround in #12 as confirmed by multiple replies.
Comment #34
angelg CreditAttribution: angelg commentedI was experiencing a weird situation with REST views and contextual filters.
I will explain it on this thread because I found the solution here.
I had a contextual filter receiving the Taxonomy Name and then validating with 'Taxonomy Term Name' validator. Also, the filter has a relation to the specific field in the node (the one with the entity reference to the taxonomy vocabulary). But this wasn't working for all the terms of the vocabulary, some of them just show 'no query was run' message and nothing were returned. (it's like the terms were not passing the validation, but they exist on the vocabulary.)
I was just almost ending the development sprint and need to set up a solution, so following the idea from #19 (perhaps that the taxo term wasn't depth)
and combining it with the awesome module from @dww
So I ended up using a contextual filter based on Term ID and using the validator "Taxonomy Term Name as ID" with the specific vocabulary. Everything works great!
Thanks guys!