Inglese: Come utilizzare i link dei termini ($terms) associati a ciascun nodo di Drupal per navigare altri contenuti dello stesso autore taggati con lo stesso termine?
Il codice di seguito permette di far puntare i termini di un nodo ad una view personalizzata (che chiameremo "blogterms") contenente due argomenti: lo user id dell'autore e il term id.
Per esempio, considerando l'URL: "blogterms/24/8":
Per ottenere questo risultato, sarà necessario inserire il seguente codice php nel template del content type interessato (es: node-blog.tpl.php)
<?php if ($terms) {
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$result = db_query('SELECT uid FROM {node} WHERE nid = %d ORDER BY uid DESC', arg(1));
// search node author in full view mode
$user = db_fetch_object($result);
$uid = $user->uid;
$nid = (int)arg(1);
} else {
$result = db_query('SELECT uid FROM {node} WHERE nid = %d ORDER BY uid DESC', $node->nid);
// search node author when you are in the blog home (/blog/6)
$user = db_fetch_object($result);
$uid = $user->uid;
$nid = $node->nid;
}
}
$terms = taxonomy_node_get_terms($nid);
$output = "<ul>";
foreach($terms as $term){
$output .= "<li><a href=\"/blogterms/" .$term->tid . "/" .$uid . "\">$term->name</a></li>";
}
$output .= "</ul>";
print t('Tags:').$output;
?>Chiaramente nella view "blogterms" andranno usati gli arguments:
Post new comment