Example:
A content type mobile has two categories
1. Price: Low, High, Medium
2. Brand: Nokia, Motorola, etc.
After going through all I found one snippet on drupal.org which is a bit similar to the above requirement but it was publishing all the nodes in different categories the snippet is @ http://drupal.org/node/76923.
Change the parameters as per your requirement.
$nid LIMIT 10 : 10 number of nodes you want to show in the block.
<code>
<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
$nid = (int)arg(1);
$terms = taxonomy_node_get_terms_by_vocabulary($nid, 3);
$output = "<ul>";
foreach($terms as $term){
$sql = "SELECT n.title, n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid = $term->tid AND n.nid != $nid LIMIT 10";
$result = db_query(db_rewrite_sql($sql));
if (db_num_rows($result)) {
$output .="<li>$term->name</li><ul>";
while ($anode = db_fetch_object($result)) {
$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output.="</ul>";
}
}
$output .= "</ul>";
return $output;
}
?>
Post new comment