Display latest X quiz titles with their creation dates
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);
}
?>
Warnings!!
I try to use it on a page but get this:
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
* warning: in_array() [function.in-array]: Wrong datatype for second argument in /homepages/21/d222132267/htdocs/drupal/includes/common.inc(1347) : eval()'d code on line 19.
After that, the items for that node (I choos story) are listed.
In the page is nothing but the snippet....
psc