Why is there no field Taxonomy: tid ?
squarecandy - April 23, 2009 - 20:01
| Project: | Views |
| Version: | 6.x-2.7 |
| Component: | taxonomy data |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Benjamin Melançon |
| Status: | needs review |
| Issue tags: | taxonomy |
Description
Hi there -
I'm a bit of a newbie, so maybe this is obvious, but I could not find the answer anywhere.
I would like to create a list of taxonomy terms that link to a path like /mycategory/nn where nn is a Taxonomy ID argument.
Why are there filters and arguments for TID but it's not available as a field?
Thanks!

#1
this is a hidden feature of views :)
here is the field taxonomy: term
see the screenshot for help, there is a rewrite output token [tid]
#2
so this is fixed
#3
It's probably not actually completely fixed. Given the new rewriting functionality, we probably now have a real need to get true access to the TID.
#4
Thanks for the screen shot dereine...
But I can't seem to replicate this in my view.
Attached are a screen shot of my "edit - field - Taxonomy: Term" and an export of my view.
Any clues for me?
Thanks!
#5
Ok - I got [tid] to appear like in deriene's screenshot by adding Field - Taxonomy: All Terms above Taxonomy: Term.
But this does not accomplish what I'm looking for. When I use the [tid] token from All Terms it gives me a text output of all of the terms associated with the node - what I want is to get the Term ID number from the list I've created with Taxonomy: Term so I can make it into a link and pass it to the URL.
So I can go from this kind of page:
http://berkfilm.srv1.graymatterhost.com/productionguide/list/2
to this one:
http://berkfilm.srv1.graymatterhost.com/productionguide/sub/81
where the last URL segment is a Term ID argument
I checked out Taxonomy Menu to try and do all of this, but I couldn't get it to do exactly what I need, so I'm trying to do it with views myself.
#6
Subscribe.
Would be useful to have the tid for advanced themeing.
Eg - Output Tid as a field [restricted by vocabulary if necessary].
Exclude from Display.
Now re-use in a template file as a class to theme the row.
It can be done by loading the full node in the temapate file, but that isn't ideal.
Regards
Alan
#7
I've also noticed that there are several threads about converting taxonomy terms with special characters to and back from the URL path, which there doesn't seem to be a good solution for... My solution was to try to use TID in the URL instead of the term name, but then realized that views provides no way of creating a link with a numeric term TID in the url.
Is there an example or guide somewhere for the best way to integrate taxonomy and views? This seems like a pretty common thing to want to do:
If someone has figured out an "ideal" way to do this and wants to share, I would be happy to help with documenting it...
Thanks!
#8
This worked for me:
http://drupal.org/node/381346
#9
Our need was to get the term ID when limiting results to a specific vocabulary... which requires the "All terms" option.
There was no 'filter terms by vocabulary, provide term id' option -- when using taxonomy all terms, the only thing providing the filter by vocabulary option, it ONLY provides the term name (as link or plain).
This patch provides a third option, for TID. It attempts to keep the original variable profile (TRUE and FALSE) for linked term and plaintext term, so that it does not affect existing sites.
#10
If it's possible to get this data without a patch, fantastic; or if this patch should be taking a very different approach, please put me in the right direction, but if this can just make life a little easier in the waning days of 2.x, I would hugely appreciate a commit.
#11
+++ modules/taxonomy/views_handler_field_term_node_tid.inc 2009-08-22 20:11:31.000000000 -0400@@ -85,14 +90,16 @@ class views_handler_field_term_node_tid
+ elseif ($this->options['link_to_taxonomy'] == TRUE) {
there is no == TRUE needed, but sure thats minor.
As far as i understand it, it shouldn't brake any existing taxonomy tid field, or?
I'm on crack. Are you, too?
#12
For squarecandy's purpose, maybe you could use "Taxonomy Redirect" module to accomplish your task. This module can rewrite typical "taxonomy/term/TERMID" path to new mapped path you want.
#13
Still using this on production and all's well, as long as the patch is in effect. Also a person at the DrupalCon Taxonomy session had this exact same problem, no term IDs available as fields. If only all questions directed my way were answered by patches written a week prior...
This works and is needed, still happy to change the implementation if there's a better way. Anyone able to test if this applies as-is to Views HEAD? It probably does but i will check or re-roll before setting this to RTBC.
#14
Subscribing. Currently looking for a way to exclude term ID from URL, just like the node. Thanks
Update: Marking this related => http://drupal.org/node/576032 :)
#15
Just tested the patch and it certainly solved my problem.
Is there any reason that TID is listed as an option on "Taxonomy: All terms". It took me a while to find it as I was expecting it to be listed as a separate field called "Taxonomy: TID".
The reason I thought this is it seems very similar to "Node: Nid" and "Node: Title".
#16
Patch from poster #9, updated to work with 6.x-2.7