Printing custom terms
Uputa kako postaviti prikaz pojmova (term) iz rječnika (taxonomy vocabulary) na stranici.
Ovaj kod kopirati u page.tpl.php
<?php
if((arg(0)=='node')&&(is_numeric(arg(1)))){
$node=node_load(arg(1));
if($node->type=='story'){
print adaptivetheme_print_terms($node, $vid = 14, $unordered_list = TRUE);
}
}
?>
Ovaj kod kopirati u template.php
// Start print custom terms.
function adaptivetheme_print_terms($node, $vid = NULL, $ordered_list = TRUE) {
$vocabularies = taxonomy_get_vocabularies();
if ($ordered_list) $output .= '<ul>'; //checks to see if you want an ordered list
if ($vid) { //checks to see if you've passed a number with vid, prints just that vid
$output = '<div class=tags-'. $vid . '>';
foreach($vocabularies as $vocabulary) {
if ($vocabulary->vid == $vid) {
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
if ($terms) {
$links = array();
$output .= '<span class=only-vocabulary-'. $vocabulary->vid . '>';
if ($ordered_list) $output .= '<div class=vocabulary-'. $vocabulary->vid . '>';
foreach ($terms as $term) {
$links[] = '<span class="term-' . $term->tid . '">' . l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description))) .'</span>';
}
$output .= implode(', ', $links);
if ($ordered_list) $output .= '</div>';
$output .= '</span>';
}
}
}
}
else {
$output = '<div class="tags">';
foreach($vocabularies as $vocabulary) {
if ($vocabularies) {
$terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
if ($terms) {
$links = array();
$output .= '<ul class=vocabulary-'. $vocabulary->vid . '>';
if ($ordered_list) $output .= '<div class=vocabulary-'. $vocabulary->vid . '>' . $vocabulary->name . ': ';
foreach ($terms as $term) {
$links[] = '<span class="term-' . $term->tid . '">' . l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description))) .'</span>';
}
$output .= implode(', ', $links);
if ($ordered_list) $output .= '</div>';
$output .= '</ul>';
}
}
}
}
if ($ordered_list) $output .= '</ul>';
$output .= '</div>';
return $output;
}

