Recent weblog entries (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 weblog titles and links to the full blogs
Dependencies: blog.module must be enabled.
Thanks to Thinkinkless and Incidental for help with improving this snippet!
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 weblog titles listed change the
$nlimitvalue in the first line of the snippet to suit. - Change the div class names or the prefix text to suit.
<?php
$nlimit = 10;
$query= "SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid = %d AND n.type = 'blog' AND n.status = 1 ORDER BY n.changed DESC";
$result = db_query_range(db_rewrite_sql($query), $account->uid, 0, $nlimit);
$output .= "<div class=\"item-list\"><ul>\n";
$output .= node_title_list($result);
$output .= "</ul></div>";
print $output; ?>Only show if there are blog entries
This is for user_profile.tpl.php:
<?php
$nlimit = 10;
$query= "SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid = %d AND n.type = 'blog' AND n.status = 1 ORDER BY n.changed DESC";
$result = db_query_range(db_rewrite_sql($query), $account->uid, 0, $nlimit);
$output .= "<div class=\"item-list\"><ul>\n";
$list = node_title_list($result);
$output .= strip_tags($list) ? $list : 'No Blog Postings available';
$output .= "</ul></div>";
print $output;
?>You can put this in a regular page set to php input filter, to display recent blog entries by the current logged in user:
<?php
global $user;
$nlimit = 10;
$query = "SELECT n.created, n.title, n.nid, n.changed FROM {node} n WHERE n.uid = %d AND n.type = 'blog' AND n.status = 1 ORDER BY n.changed DESC";
$result = db_query_range(db_rewrite_sql($query), $user->uid, 0, $nlimit);
$list = node_title_list($result);
$output = '<h2>Latest Posts:</h2>';
$output .= strip_tags($list) ? $list : 'No Blog Postings available';
return $output;
?>Limit the Content
This actually shows all content posted, like storys, blog and audio or whatever else you have.
to have it specific do this
<?php
$nlimit = 10;
$userid=$user->uid;
$query= "SELECT n.created, n.title, n.nid, n.changed FROM node n WHERE n.uid = $userid AND n.type = 'blog' AND n.status = 1 ORDER BY n.changed DESC";
$result = db_query_range($query,0,$nlimit);
$output .= "<div class=\"item-list\"><ul>\n";
$output .= node_title_list($result);
$output .= "</ul></div>";
print $output;
?>adding AND n.type = 'blog' to the WHERE part.

Add "Edit" Link?
Is there a way to modify this so that it also shows a link to add the the posts that come up?