I am going to check whether a term belongs to a designated vocabulary.
Which function is used to get vocabulary by term or node?
欢迎各位兄弟 发布技术文章
这里的技术是共享的
I am going to check whether a term belongs to a designated vocabulary. Which function is used to get vocabulary by term or node? | ||||
add comment |
In Drupal 6, if you know the taxonomy term ID, you can get the vocabulary ID by using the following code:
If you have a node ID, then you can use the following code to get the vocabulary ID of all the taxonomy terms associated with the node using the following code:
In Drupal 7, the code would be the following:
In Drupal 7, the node property
Using field_get_items(), you would get the taxonomy terms in the language they would be displayed, or in the language whose code is passed as argument to the function.
| ||||
add comment |
Solved by the code below:
| |||
add comment |
For Drupal 7 the above code should be like this:
See more examples at db_query() drupal 7 function. |
来自 http://drupal.stackexchange.com/questions/6456/get-the-vocabulary-id-by-term-or-node