/[drupal]/contributions/tricks/blocks/mostrecentcomments.php
ViewVC logotype

Contents of /contributions/tricks/blocks/mostrecentcomments.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Mon Jan 24 03:59:56 2005 UTC (4 years, 10 months ago) by chris
Branch: MAIN
Changes since 1.3: +4 -5 lines
File MIME type: text/x-php
Change deprecated node/view/x to node/x/view.
1 <?php
2 /*
3 * This PHP-type block displays a list of the authors and subjects of
4 * the most recent comments in a table.
5 *
6 * $Id: mostrecentcomments.php,v 1.3 2003/08/16 23:02:16 chris Exp $
7 * Author: Chris Johnson / chris@tinpixel.com
8 */
9
10 /*
11 * The current database query below looks for comments newer than 7 days
12 * (24 hours * 3600 seconds),
13 * orders the results by timestamp (newest first) and limits it to
14 * first 3 found. These values are easily changed.
15 */
16
17 $result = db_query("Select name, subject, cid, nid
18 From {comments} c, {users} u
19 Where u.uid = c.uid
20 And c.timestamp > (unix_timestamp(now()) - 3600*24*7)
21 Order By c.timestamp Desc
22 Limit 3");
23
24 $header = array(t("Name"), t("Subject")); // table column titles
25 while ($comm = db_fetch_array($result)) {
26 $rows[] = array($comm['name'] , '<a href="node/'. $comm['nid'] .'#' . $comm['cid'] . '/view">'. substr($comm['subject'],0,30) .'</a>');
27 }
28
29 $output .= table($header, $rows);
30
31 return $output;

  ViewVC Help
Powered by ViewVC 1.1.2