Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Donovan on
I've been trying to figure out how to do this with no success. What I would like to do is to provide a list of blogs (i.e., blog *titles*, not blog entries) in a block. It seems like the code (posted by mabster) can be tweaked to do this, but I can figure out what to change.
global $user;
if (user_access("access content")) {
$blogs = "";
$queryResult = db_query_range("SELECT n.uid, u.name, max(n.nid) FROM {node} n INNER JOIN {users} u ON u.uid = n.uid WHERE n.type = 'blog' AND n.status = 1 GROUP BY n.uid, u.name ORDER BY 3 DESC", 0, 3);
while ($node = db_fetch_object($queryResult)) {
$blogs .= l(t("<h3>%username</h3>", array("%username" => $node->name)), "blog/$node->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $node->name))))
. node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = " . $node->uid . " ORDER BY n.nid DESC", 0, 3));
}
return $blogs
. "<div class=\"more-link\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
}
I would appreciate any suggestions on modifications to accomplish this. Thx,
Donovan.