When creating a fresh "node" view, "Taxonomy: Term ID" doesn't show up in the list of avaible fields. Seems to be related to "'skip base' => array('node', 'node_revision')," in taxonomy.view.inc on line 101 because everything's working since I removed that line.

CommentFileSizeAuthor
#4 patch_views_taxonomy_inc.txt604 bytesayalon

Comments

liquidcms’s picture

yes, this would fix my problem:

i am trying to create a view that has title's that link to another view with an argument.

view1 - stuff categories, with list of "stuff taxonomy nodes" (using nat)
- this view has each node with a title that should link to

view2 - list of stuff nodes that are tagged with a "stuff tax term"

ideally title links in view1 would have urls that were SEO happy and use term name rather than id, but example terms is "know & grow" and even though this works in the views preview, i can't get it to work for real in the url.

so fall back is to use term id - BUT.. i can't get that as a field (issue posted here) so i can't use it as a token to re-wrtie my title urls.

i am think above was pretty confusing.. lol...

view1 = stuff_cats
- teaser list with each title having url like /stuff/1 (but can't get term id to make this url) or stuff/know-&-grow (which doesn't work since i can't get & to pass through)

but, view2, which is at /stuff/%1 does work in preview when i enter "know & grow" as argument.

liquidcms’s picture

and yup, commenting out the line you pointed out above gives me back Term ID as a field and now i can make this work (albeit in the less seo happy form)

thanks.

mlncn’s picture

Commenting out that line solves the issue with no ill effects? At the design camp session on views 2 theming a workaround for this is being presented.

If this is a solid fix we should submit a patch.

ayalon’s picture

StatusFileSize
new604 bytes

I had to comment out this line too, because we really need the Term ID as a token to rewrite URLs!

Please remove this line in views.taxonomy.inc

I made a patch for the latest dev version 2.x

attiks’s picture

It wasn't working for me probably because i was filtering on 1 vocabulary and needed the tid of another one, so I used 'Taxonomy: All terms' field limited to the vocabulary i needed and in my tpl.php is used this to extract the tid

    $xyzzy = array_keys($fields['tid']->handler->items[$fields['nid']->content]);
    print_r ($xyzzy[0]);
sammys’s picture

Version: 6.x-2.3 » 6.x-2.6
Status: Active » Needs work

The patch in #4 works as described. Using 2.6 there is no Taxonomy: Term ID field available. Before patching there is no way to get the numeric ID from the view. This is especially important when using global text fields or rewriting the output of other fields with the term ID.

The patch doesn't show a field setting to specify the vocabulary for the field. Marking the issue as needs work as it does IMHO. Maintainers?

merlinofchaos’s picture

Status: Needs work » Needs review

There shouldn't be. That's only in use for 'all terms' which will load every term. If you need a tid from a specific vocabulary you have the same issues as you'll have with the Taxonomy: Term field.

attiks’s picture

Merlin,

Can you give me feedback on the solution in #5, are there better ways the achieve this? It would be easy to just select a Taxonomy Term field and limit it to one particulary vocabulary, and maybe add 2 display options: TermId or Term

merlinofchaos’s picture

all terms is going to need a more complicated rewrite methodology. I have something in mind, but it's fairly separate from this.

merlinofchaos’s picture

Status: Needs review » Fixed

Applied to 2.x and 3.x branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mlncn’s picture

See http://drupal.org/node/443186 for a patch that addresses the problem of displaying the term ID.

ben, agaric