in drupa开发者_StackOverflow社区l, after installing the taxonomy node module, I can create a node explaining the taxonomy term. That's working fine.
Now, I would like to list the taxonomy terms of a giving node where each term of the list is a link to the node of that term.
In another words:
$listOfTaxonomyTerms = taxonomyTermsByNode($nodeID);
$linkToTaxonomyNode = TaxonomyNodeLinkByTerm($listOfTaxonomyTerms[0]);
I'm sorry to answer my own question. It wouldn't fit the comment text area.
I guess I just needed to make the question to start thinking about the answer. So, I made a function on template.php. This collects the urls to the taxonomy nodes and makes some links with the taxonomy terms:
function listaNodeSectores($geturl){
//get alias of URL
$path = drupal_get_path_alias($geturl['q']);
//break path into an array
$pathArray = explode('/', $path);
$arraysize = sizeof($pathArray);
if ($arraysize>0) {
$nodeId = $pathArray[$arraysize - 1];
}
// echo "nodeID: ".$nodeId;
$node = node_load($nodeId);
$termos = taxonomy_node_get_terms($node);
foreach($termos as $term){
$termNodeID = _taxonomynode_get_nid_from_tid($term->tid) ;
$termNode = node_load($termNodeID);
$tmp = $pathArray;
$tmp[$arraysize - 1] = $termNodeID;
$tmp2 = implode('/', $tmp);
// devolve os urls completos:
$termNodeUrls[] = '<a href="'.url($tmp2).'">'.$termNode->title.'</a>';
}
return $termNodeUrls;
}
精彩评论