I need to display the term ids of each node under its title in a view.

I can do similar display by adding node: title and node: all taxonomy terms. But I just want to display tid's instead of term names.

My view result should look like this:

title: Node title 1

tids: 1, 2, 4

title: Node title 2

tids: 3, 5, 6

Is there a way to alter or add a views field for this?

Also in general, how are fields that is available to the views constructed?

2 Answers 2


Add field "All taxonomy terms". Then check the "rewrite output of this field" box, and in the rewrite box enter the token [term_node_tid-tid].

  • Thanks beth, but when i do this, it will display the same node for each term. "All taxonomy terms" field is special that it aggregates all terms of a node and displays all of them in the same row as a list, or comma separated. Dec 19, 2012 at 7:48
  • If you exclude node title from display and then use it as a grouping field, you'll get a list of all the TIDs underneath. You can then use CSS to put them all on the same line.
    – beth
    Dec 19, 2012 at 15:33
  • I found a much better solution and amended my answer.
    – beth
    Dec 19, 2012 at 15:57
  • There is no such field named "terms on node" as far as I know. Can you expand your answer? Do you add relationships? Which table you are using to create your view (node, term, etc)? Dec 20, 2012 at 16:44
  • Whoops, sorry, the name is "All taxonomy terms". This can be used either with a node-based view, or a term-based view via a "nodes with term" relationship.
    – beth
    Dec 20, 2012 at 18:25

Addition to the @beth 's answer:

"all taxonomy terms" field apparently provides multiple replacement tokens:

[term_node_tid] == Content: All taxonomy terms [term_node_tid-tid] == The taxonomy term ID for the term. [term_node_tid-name] == The taxonomy term name for the term. [term_node_tid-vocabulary-machine-name] == The machine name for the vocabulary the term belongs to. [term_node_tid-vocabulary] == The name for the vocabulary the term belongs to.

Hidden gem :) I wonder how many other fields come with similar behavior..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.