Display latest X quiz titles with their creation dates
Last modified: November 19, 2007 - 11:01
The code below displays in a block (or a php page) latest X (configurable in the code) quizes.
<?php
$list_no = 3;
$query = "SELECT DISTINCT n.nid, n.title, n.created
FROM {node} n
WHERE n.type = 'quiz' AND n.status = 1
ORDER BY n.created DESC
LIMIT $list_no";
$sql = db_rewrite_sql($query);
$result = db_query($sql);
$items = array();
while ($anode = db_fetch_object($result)) {
$term_names = array();
# gather, into $term_names, all the terms because of which this node was selected:
foreach (taxonomy_node_get_terms($anode->nid) as $term) {
if (in_array($term->tid, $taxo_id_arr))
$term_names[] = $term->name;
}
$items[]= l($anode->title, "node/$anode->nid") .
'<br />' .
'Created ' . format_date($anode->created, 'custom', 'Y-m-d') . '.';
}
if(count($items)) {
print theme('item_list',$items);
}
?>