在theme裏區別顯示一般分類與freetag標籤

add this function to template.php


function phptemplate_preprocess_node(&$vars) {
// If we have any terms...
if ($vars['node']->taxonomy) {
// Let's iterate through each term.
foreach ($vars['node']->taxonomy as $term) {
// We will build a new array where there will be as many
// nested arrays as there are vocabularies
// The key for each nested array is the vocabulary ID.
$vocabulary[$term->vid]['taxonomy_term_'. $term->tid] = array(
'title' => $term->name,
'href' => taxonomy_term_path($term),
'attributes' => array(
'rel' => 'tag',
'title' => strip_tags($term->description),
),
);
}
// Making sure vocabularies appear in the same order.
ksort($vocabulary, SORT_NUMERIC);
// We will get rid of the old $terms variable.
unset($vars['terms']);
// And build a new $terms.
foreach ($vocabulary as $vid => $terms) {
// Getting the name of the vocabulary.
$name = taxonomy_vocabulary_load($vid)->name;
// Using the theme('links', ...) function to theme terms list.
$terms = theme('links', $terms, array('class' => 'links inline'));
// Wrapping the terms list.
$vars['terms'] .= '<div class="vocabulary taxonomy_vid_';
$vars['terms'] .= $vid;
$vars['terms'] .= '">';
$vars['terms'] .= $name;
$vars['terms'] .= ': ';
$vars['terms'] .= $terms;
$vars['terms'] .= '</div>';
}
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章