Community Documentation

OUTDATED: Recent updates: latest added or changed nodes in a site

Last updated September 12, 2008. Created by Wolfflow on September 22, 2005.
Edited by pwolanin, kbahey. Log in to edit this page.

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> | ';
?>

About this page

Drupal version
Drupal 4.6.x, Drupal 4.7.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here