Download & Extend

Add a "Recent posts" block to the tracker module

Project:Drupal core
Version:6.x-dev
Component:tracker.module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

See my article at http://drupal.org/node/287#comment-87175

Comments

#1

Used the query (unmodified) from the tracker module and added the hook_block function to it. It can be inserted in the tracker.module.

/**
* Implementation of hook_block().
*/
function tracker_block($op = 'list', $delta = 0) {
  global $user;
 
  if ($op == 'list') {
    $blocks[0]['info'] = t('Recent posts');
   
    return $blocks;
  }
  else if ($op == 'view') {
    $sql = 'SELECT DISTINCT
        (n.nid),
        n.title,
        n.type,
        n.changed,
        n.uid,
        u.name,
        l.last_comment_timestamp as last_post,
        l.comment_count
      FROM
        {node} n
        INNER JOIN {users} u on n.uid = u.uid
        INNER JOIN {node_comment_statistics} l on n.nid = l.nid
      WHERE
        n.status = 1
      ORDER BY
        last_post desc
      LIMIT 0, 16';
     
    $sql = db_rewrite_sql($sql);
    $result = db_query($sql);
 
    $rows = array();
    while ($node = db_fetch_object($result)) {
      $rows[] = l($node->title, "node/$node->nid");
    }
 
    $block['content'] = theme_item_list($rows);
    $block['subject'] = t('Recent posts');
   
    return $block;
  }
}

#2

This query works fine for me:

    $sql = 'SELECT DISTINCT
        nid,
        title,
        changed
      FROM
        {node} n
      WHERE
        status = 1
      ORDER BY
        changed desc
      LIMIT 0, 16';

#3

Version:4.6.5» x.y.z
Category:task» feature request

Can you please:

a) make this more generic? i.e. give the admin choice to choose the node-types, number of entries etc.?
b) also add a recent comments block? (with similar choices)

We can then get rid of the two blocks in the forum module.

Thanks,
-K

#4

Status:active» needs work

And please submit it in patch form.

Thanks,
-K

#5

Version:x.y.z» 6.x-dev
Status:needs work» active

#6

The block works fine with the top snippet added but when a user comments on an article it makes that article jump back to the top of the list. I would like user comments not to be taken into account and only the publication date.

I am clueless as to what to remove from the snippet.

Regards

Sven

#7

Status:active» needs review

I have created a patch to allow a block for the tracker module.

(its my first real patch, be gentle!)

AttachmentSizeStatusTest resultOperations
tracker.module.patch770 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch tracker.module_2.patch.View details | Re-test

#8

Subscribing, will test if this works!
This is may be also a way to go: http://www.glennburks.com/blogs/glenn/using-drupal-6-views-create-offset....

Greetings, Martijn

#9

Status:needs review» needs work

The last submitted patch, tracker.module.patch, failed testing.