Drupal中的分类(Taxonomy)用法 (转)

 1、$term=taxonomy_get_term($tid);


得到$term对象

Term_data表中的所有数据

$term->vid,

$term->name,

$term->decription

 

2、$vocabulary = taxonomy_vocabulary_load($vid);

得到$vocabulary对象

Vocabulary表中的所有数据及此vid对应的node type

$vocabulary->name,

$vocabulary->decription,

$vocabulary->vid,

$vocabulary->nodes   (注:得到node type的数组)

 

3、$term = taxonomy_get_term_by_name($name)

通过分类名字,得到此分类的$term对象,取得Term_data表中的所有数据

如1的$term对象

 

4、taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC')

通过tid数组得到此数组下的所有文章的nid,title,created,sticky

$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1 ORDER BY ' . $order;  (注:DISTINCT:不同的)

$tids = array(5,6);

$results = taxonomy_select_nodes($tids,'and');

$titles = array();

While($data = db_fetch_object($results)){

$titles[] = $data->title;

}

5、taxonomy_get_vocabularies($type = NULL)

$type为node type 如blog,返回此node type所有的分类对象(即:return an array of vocabulary objects )  vocabulary对象和2一样

 

6、taxonomy_node_get_terms($node,$key);

$node为$nid,$key默认为$tid

取得一个节点的所有分类

Return an array of arrays ,keyed by $key

7、taxonomy_node_get_terms_by_vocabulary($node,$vid,$key);

详解如6

 

8、taxonomy_get_parents($tid,$key)

Return an associative array of term objects,keyed by $key

9、taxonomy_get_parents_all($tid)

The function return an array of term objects

10、taxonomy_get_children($tid,$vid,$key)

转载于:https://www.cnblogs.com/ginikeer/p/3554719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值