I need to display the most recent story titles for (x)Taxonamy ID. without a teaser. just the title and have it link to the story.

Thanks
-Jeff

Comments

wdrupal’s picture

You could try something like this:

<?php
// only story nodes
$node_type = "story";
// only the five latest titles here:
$list_no = 5;
// get some nodes
$sql = "SELECT node.title, node.type, node.nid, node.created FROM node WHERE node.type = '$node_type' ORDER BY node.created DESC LIMIT $list_no";
$output .= "<ul>";
$result = db_query($sql);
while ($anode = db_fetch_object($result)) {
    $output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
print $output;
?>

That version will not limit by taxonomy, but I know it works. The next version is untested, but should limit you by taxonomy:

<?php
// only story nodes
$node_type = "story";
// only the five latest titles here:
$list_no = 5;
// limit by taxonomy
$taxonomy_id = 1;

// get some nodes
$sql = "SELECT node.title, node.type, node.nid, node.created FROM node WHERE node.type = '$node_type' AND term_node.tid = $taxonomy_id ORDER BY node.created DESC LIMIT $list_no";
$output .= "<ul>";
$result = db_query($sql);
while ($anode = db_fetch_object($result)) {
    $output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
print $output;
?>

Let me know if that works...