Recent updates: latest added or changed nodes in a site

PLEASE NOTE These snippets are user submitted. Use at your own risk. For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

Here is a snippet that will provide a "Recent updates" block with a link to the tracker for the full list.

<?php
$num_nodes
= 7;

$result = db_query_range(db_rewrite_sql('SELECT n.nid, n.title
FROM {node} n
WHERE n.status = 1 ORDER BY n.changed DESC'
), 0, $num_nodes);

$output = node_title_list($result);
$output .= l('More articles ...', 'tracker');

print
$output;
?>

sweet

dreamYu - December 18, 2005 - 19:03

this snippet is very helpful, but is there a way to show in addition the category of each node?

to get the

mpamphile - April 26, 2006 - 05:33

to get the categories

$categories = taxonomy_node_get_terms($node->nid);
foreach ($categories as $category) {$superterms .= '<a href="taxonomy/term/' . $category->tid . '">' . $category->name . '</a>';        $superterms .= '<a href="taxonomy/term/' . $category->tid . '/0/feed"><img src="misc/xml.png" alt="rss feed" class="termy" /></a> | ';

Marcel
http://www.bigvertiser.com
http://01wholesale.com

 
 

Drupal is a registered trademark of Dries Buytaert.