function garland_separate_terms($node_taxonomy) {
if ($node_taxonomy) {
foreach ($node_taxonomy AS $term) {
$links[$term->vid]['taxonomy_term_'. $term->tid] = array(
'title' => $term->name,
'href' => taxonomy_term_path($term),
'attributes' => array(
'rel' => 'tag',
'title' => strip_tags($term->description)
),
);
}
//theming terms out
foreach ($links AS $key => $vid) {
$terms[$key] = theme_links($vid);
}
}
return $terms;
}
我无法很好地理解这个功能。
($node_taxonomy=array())
。$links[$term->vid]['taxonomy_term_'. $term->tid]
来自何处?答案 0 :(得分:1)
他希望$node_taxonomy
包含特定节点的所有术语。 Each term is an object that contains attributes like vid,tid,name,description and path.
$ links是他正在创建的新数组。
所以基本上如果一个特定节点的词汇a1,a2,a3来自词汇表a和术语b1,b2来自词汇表b,那么数组将把它存储为
$links[a][a1] = details of a1 to convert into link
$links[a][a2] = details of a2 to convert into link
$links[a][a3] = details of a3 to convert into link
$links[b][b1] = details of b1 to convert into link
$links[b][b2] = details of b2 to convert into link
最后,他使用theme_links()函数指示$ links的每个元素。
最后,您将获得所有术语的列表,作为按词汇表分组的链接。