<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$node = node_load(arg(1));
foreach ($node->taxonomy as $vid => $term) {
$vn = taxonomy_vocabulary_load($term->vid);
$t[$vn->name][$term->tid]['name'] = $term->name;
}
$output = '';
foreach ($t as $key => $value){
$output .= '<fieldset class="fieldgroup collapsible"><legend>'.$key.'</legend>';
foreach($value as $b => $a){
$output .= '<div class="field-item odd">';
$output .= l($a['name'], 'taxonomy/term/' . $b) . ' ';
$output .= '</div>';
}
$output .= '</fieldset>';
}
print $output;
}
?>
La ide que tenia era aprofitar aquesta funció per fer que Drupal cridés a una icona segóns la taxonomia.
Així que amb l'ajud del bon amic Carlos d'Interdixit hem aconseguit l'objectiu:
<img src="/dev/sites/all/themes/omega/css/img/premsa_ikon<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$node = node_load(arg(1));
foreach ($node->taxonomy as $vid => $term) {
$vn = taxonomy_vocabulary_load($term->vid);
$t[$vn->name][$term->tid]['name'] = $term->name;
}
$output = '';
foreach ($t as $key => $value){
foreach($value as $b => $a){
$output .= $a['name'];
}
} print $output;
}
?>.png">
Font: http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/function/taxonomy_node_get_terms/6
Cap comentari:
Publica un comentari a l'entrada