Display list of (x) recent posts (titles) snippet
PLEASE NOTE! These snippets are user submitted. It is impossible to check them all, so please 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.
Description
This php snippet displays a list of the (x) most recent posts by the user and a links to the full nodes.
Dependencies: none.
Usage
- For use in your 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
$nlimitvalue to suit. The default setting is 5. - Change the div class names or the prefix text to suit.
<div class="fields">
<p>Recent Posts</p>
<?php
$output = '';
$uid = arg(1);
$nlimit = 5;
$result = db_query(db_rewrite_sql("SELECT n.created, n.title, n.nid, n.changed
FROM {node} n
WHERE n.uid = %d
AND n.status = 1
ORDER BY n.changed
DESC LIMIT %d"), $uid, $nlimit);
$output .= '<div class="item-list"><ul>' . "\n";
$output .= node_title_list($result);
$output .= '</ul></div>';
print $output;
?>
</div>
Has something gone wrong in the reorganisation?
It seems illogical that this snippet should be stored under "customizing user profile" - it is a general block snippet... When looking at the other things in this book section, it seems that many things are seriously misplaced.