Display a list of node titles of a specific type, within certain dates/times
Last modified: January 8, 2007 - 22:18
Note from the moderator: Thank you for sharing the snippet with the Drupal community. In its current state the snippet might present security risks. See Writing secure code for a background on the most common problems.
Specifically, the snippet
- bypasses node access restrictions; you should usually pass queries through db_rewrite_sql.
<?php
/**
* Creates a list of node titles of a specific type, within certain dates
* with a link to each node.
*
* To change which type is listed, simply edit the $node_type string.
* To change the starting date, simply change the $start_stamp.
* To change the ending date, simply change the $end_stamp.
*
* This works with Drupal 4.6
*/
$node_type = "image";
$start_stamp = 'June 9 2005';
$end_stamp = 'June 10 2005';
$start_stamp = strtotime($start_stamp);
$end_stamp = strtotime($end_stamp);
$sql = "SELECT node.title, node.nid FROM node WHERE node.created < $end_stamp AND node.created > $start_stamp AND node.type = '$node_type'" ;
$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;
?>