Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
/**
* Creates a neat table of flexinode titles from a specified term
* with a link to each one and 'submitted by...' information.
*
* $field_id must point to the flexinode field which contains the date.
* To change which term is listed, simply edit the $term_id string.
* To change the number of results listed, simply edit the $list_no number.
*
* This works with Drupal 4.6 and Drupal 4.7
*/
$term_id = 75;
$field_id = 9;
$list_no = 25;
$prev_year = '';
$sql = db_rewrite_sql("SELECT n.nid, n.title, n.created, u.name, fl.numeric_data
FROM {node} n
INNER JOIN {users} u ON n.uid = u.uid
INNER JOIN {term_node} tn ON n.nid = tn.nid
INNER JOIN {flexinode_data} fl ON n.nid = fl.nid
WHERE tn.tid = %d AND fl.field_id = %d
ORDER BY fl.numeric_data DESC");
$result = pager_query(sprintf($sql, $term_id, $field_id), $list_no);
while ($anode = db_fetch_object($result)) {
$year = format_date($anode->numeric_data, 'custom', 'Y');
$month_day = format_date($anode->numeric_data, 'custom', 'M j');
if ($year != $prev_year) {
$prev_year = $year;
}
$output[$year][] = array(array('data' => $month_day), array('data' => l($anode->title, "node/$anode->nid")), array('data' => '<em>Submitted by '.$anode->name."</em>"));
}
foreach ($output as $year => $table) {
print theme('table', array(array('data' => '<h3>'.$year.'</h3>', 'colspan' => '3')), $table);
}
print theme('pager', NULL, $list_no);
Pobster