[drupal-devel] [feature] Recent nodes/comments block (patch attached)

Dublin Drupaller drupal-devel at drupal.org
Sun May 15 10:15:46 UTC 2005


Issue status update for http://drupal.org/node/19387

 Project:      Drupal
 Version:      4.5.2
 Component:    tracker.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  hba
 Updated by:   Dublin Drupaller
 Status:       patch

..worked that out for myself...the following snippet creates a list of
recent forum topics and active forum topics...


Can be used in a drupal page or block (with the filter set to PHP)


<?php
$content  = node_title_list(db_query_range("SELECT DISTINCT(n.nid),
n.title, l.last_comment_timestamp FROM {node} n INNER JOIN
{node_comment_statistics} l ON n.nid = l.nid ". node_access_join_sql()
." WHERE n.status = 1 AND n.type='forum' AND ". node_access_where_sql()
." ORDER BY l.last_comment_timestamp DESC", 0,
variable_get('forum_block_num', '5')), t('Active forum topics:'));
      $content .= node_title_list(db_query_range("SELECT
DISTINCT(n.nid), n.title FROM {node} n ". node_access_join_sql() ."
WHERE n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql()
." ORDER BY n.nid DESC", 0, variable_get('forum_block_num', '5')),
t('New forum topics:'));
      if ($content) {
        $content .= '<div class="more-link">'. l(t('more'),
'forum', array('title' => t('Read the latest forum topics.')))
.'</div>';
      }
print $content;
?>


I'm trying to get the tracker_page function SQL query to filter out by
n.type='forum' ..but I'm not sure how to do that....can you help by any
chance?


here's a thread on that specific topic...


http://drupal.org/node/22881


Cheers


Dub




Dublin Drupaller



Previous comments:
------------------------------------------------------------------------

March 24, 2005 - 16:59 : hba

Attachment: http://drupal.org/files/issues/tracker.module.recent.posts.block.patch (1.59 KB)

This patch adds a recents posts/nodes/comments block to tracker.module. 



It is better than the 'recent comments' block in comment.module in my
opinion: this block includes recent nodes/images/events/etc. as well,
and it uses less space.


The patch is for 4.5.2, but I guess it would work with few adjustments
(if any) on 4.6.x.




------------------------------------------------------------------------

May 15, 2005 - 11:00 : Dublin Drupaller

Heisen...


Great patch...works perfectly.


Just curious if you know how to restrict the output to just list recent
forum posts & comments...as opposed to listing all types of nodes.


Takk skal du har!


Dub







More information about the drupal-devel mailing list