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

dereine - April 24, 2009 - 19:58

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]

AttachmentSize
screenshot3.png 25.3 KB

#2

dereine - April 24, 2009 - 19:58
Status:active» fixed

so this is fixed

#3

merlinofchaos - April 24, 2009 - 20:01
Status:fixed» active

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

squarecandy - April 28, 2009 - 22:20

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!

AttachmentSize
Picture 60.jpeg 122.45 KB
listing-view.txt 4.39 KB

#5

squarecandy - April 28, 2009 - 22:49

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

alanburke - May 15, 2009 - 13:45

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

squarecandy - May 26, 2009 - 05:18

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:

  • A taxonomy hierarchy of terms as a way of organizing content and avoiding creating duplicate content (a node can belong to more than one taxonomy category - a taxonomy category can have special characters in the name)
  • A view to list the content items in a certain category [linking to:]
  • A second view for the individual node with a breadcrumb indicating the category you got there from (not just a list of all categories that node exists in)

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

Max_Headroom - June 2, 2009 - 05:36

This worked for me:
http://drupal.org/node/381346

#9

Benjamin Melançon - August 23, 2009 - 00:33

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.

AttachmentSize
views-taxonomy-tid-field-for-all-terms-vocabulary-restricted-443186-9.patch 1.82 KB

#10

Benjamin Melançon - August 23, 2009 - 00:39
Version:6.x-2.5» 6.x-2.6
Assigned to:Anonymous» Benjamin Melançon
Status:active» needs review

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

dereine - August 23, 2009 - 05:41

+++ 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

shadowx - September 11, 2009 - 06:46

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

Benjamin Melançon - September 20, 2009 - 16:32
Version:6.x-2.6» 6.x-2.x-dev

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

gausarts - September 20, 2009 - 17:26

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

SeanBannister - October 6, 2009 - 15:29

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

verot - November 10, 2009 - 11:02
Version:6.x-2.x-dev» 6.x-2.7

Patch from poster #9, updated to work with 6.x-2.7

AttachmentSize
views-taxonomy-tid-field-for-all-terms-vocabulary-restricted.patch 2.25 KB
 
 

Drupal is a registered trademark of Dries Buytaert.