Sometimes people ask me about some stuff I have done on my Drupal sites, like this blog or Spaniards.es. I was just updating the Popular items page and I thought it would be nice to paste the code here. After all, is very simple, but still it may help newbies :)
<?php
$sql = "select n.title, n.nid, nc.totalcount, n.created
from node n
join node_counter nc on n.nid = nc.nid
where n.type = 'story'
order by nc.totalcount desc limit 0,100";
$result = db_query($sql);
$output = '';
while ($anode = db_fetch_object($result)) {
$output .= "" .
date('M d, y', $anode->created) . " " .
l($anode->title, "node/$anode->nid") .
" ($anode->totalcount reads)
";
}
print "$output
";
?>
PS: This doesn't follow Drupal's standards.
Submitted by Eneko Alonso on Wed, 2008-05-07 20:38
Post new comment