OUTDATED: Recent updates: latest added or changed nodes in a site
Last modified: September 12, 2008 - 23:27
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;
?>Show in addition the category of each node
Code to get the categories:
<?php
$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> | ';
?>