CommentFileSizeAuthor
#7 tracker.module.patch770 bytessiromega
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

he_who_shall_not_be_named’s picture

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;
  }
}


he_who_shall_not_be_named’s picture

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';
Zen’s picture

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

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

Zen’s picture

Status: Active » Needs work

And please submit it in patch form.

Thanks,
-K

bdragon’s picture

Version: x.y.z » 6.x-dev
Status: Needs work » Active
Yoda99’s picture

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

siromega’s picture

Status: Active » Needs review
FileSize
770 bytes

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

(its my first real patch, be gentle!)

Summit’s picture

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

Status: Needs review » Needs work

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

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.