Posted by Jason Sale on October 27, 2010 at 5:33am
2 followers
Jump to:
| Project: | Node Comments |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
A new install of Node Comments seems to kill the "Recent Comments" block on my install. I could create a new block using the Featured Content module that displays recent Comments, but this only links to the node, not the comment (to the user, that's pretty cumbersome because seeing the original content requires clicking on the breadcrumb). Showing recent comments this way displays
/content/comment_name
when we should be seeing
/node_name#comment-123
Anyone got a solution for this short of creating a dodgy uncached php script or writing a new module? The ideal solution would be if this worked out-of-the-box in Node Comments...
Comments
#1
Then again, creating a block and putting the php code in there does allow it to be cached, fixing my problem. Here is the block content I used to get the "recent comments" block:
<?php
<?php
$limit = 10;
$sql = db_query("SELECT nc.nid nid, nc.cid cid, n.title title FROM {node_comments} nc, {node} n WHERE nc.cid = n.nid AND n.type = 'comment' ORDER BY n.created DESC LIMIT %d", $limit);
$block = '<ul class="menu">';
unset($i);
while ($n = db_fetch_object($sql)) {
if ($i) {
$block .= '<li class="leaf">';
}
else {
$block .= '<li class="leaf first">';
$i = TRUE;
}
$path = drupal_get_path_alias('node/' . $n->nid);
$block .= '<a href="';
$block .= url($path, array()) . '#comment-' . $n->cid . '">';
$block .= $n->title . '</a>';
$block .= '</li>';
}
$block .= '</ul>';
return $block;
?>
ofcourse I'd prefer some sort of drupal theming function for the lists but I dunno where that is so if someone could let me know that'd be great.
cheers
?>
#2
Why don't you use Views for that ?
#3