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 node titles
* with a link to each one and 'submitted by...' information.
* As this snippet uses the event module to sort entries you must make
* sure to enable users to enter dates for the content type under "Show in event calendar:"
*
* $node_type must contain a valid content type NOT the content name.
* To change the number of results listed, simply edit the $list_no number.
*
* This has been tested and works with Drupal 6.x
*/
$node_type = 'results_page'; // I'm using a custom node type here to demonstrate you use the node type rather than the name
$list_no = 25;
unset($prev_year);
$sql = "SELECT n.nid, n.uid, n.title, u.name, e.event_start
FROM {node} n
INNER JOIN {event} e ON n.nid = e.nid
INNER JOIN {users} u ON n.uid = u.uid
WHERE n.type = '%s'
ORDER BY e.event_start DESC";
$result = pager_query(db_rewrite_sql(sprintf($sql, $node_type)), $list_no);
while ($node = db_fetch_object($result)) {
$date = event_explode_date($node->event_start);
if ($date['year'] != $prev_year) {
$prev_year = $date['year'];
}
$output[$date['year']][] = array(array('data' => date("M jS", mktime(0, 0, 0, $date['month'], $date['day']))), array('data' => l($node->title, "node/$node->nid")), array('data' => '<em>Submitted by '. l($node->name, 'user/'. $node->uid) ."</em>"));
}
foreach ($output as $date['year'] => $table) {
print theme('table', array(array('data' => '<h3>'. $date['year'] .'</h3>', 'colspan' => '3')), $table);
}
print theme('pager', NULL, $list_no);
Comments
to enable users to enter dates for the content type
You need to have:
1- Installed the Event module (http://drupal.org/project/event)
2- Enabled this module in Administer/Modules section
3- Enabled one or more node types to be used with the event system (you can follow the indications of “INSTALL.txt” file, located in the Event module installation package)
Note 1: If isn't any event to show, you will get the warning
You can avoid that declaring the variable
$output
as an empty array before thewhile
statement.Note 2: If you want to show the events related to nodes of type "
page
" you only have to put that value replacing the custom node type "results_page
" in the code.hi
I enabled the Php input format and when i create a page i put your code in my body of the page but it just display the code. is there any problem with the PHP input formats in drupal 6.10?..
Thank you
You actually need to select
You actually need to select the php input format in your post, look just below the body field.
Pobster