Tuesday, January 27, 2009

Display recent nodes (titles & teasers) snippet

Description

This php snippet displays the 10 most recent nodes submitted by the user, restricting certain node types. In this example, pages, stories, and forum posts are excluded from the list.

Usage

• For use in a user profile page override
• Using a text editor like NOTEPAD.EXE or an equivalent, copy and paste the code into your user_profile.tpl.php file
• To increase/decrease the number of posts listed change the $nlimit value to suit. The default setting is 10.
• Tested and works with Drupal 4.6
• Change the div class names or the prefix text to suit.

= 10; ?>
=$user->uid; ?>
= pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.uid = $userid AND n.type != 'page' AND n.type != 'poll' AND n.type != 'forum' AND n.type != 'story' ORDER BY n.created DESC"), variable_get('default_nodes_main', $nlimit)); ?>
while ($node = db_fetch_object($result1)) {$output2 .= node_view(node_load(array('nid' => $node->nid)), 1);}; ?>
print $output2; ?>

No comments: