PDA

View Full Version : drupal native comments.module


Caerydd
04-16-2006, 07:51 PM
Okay, after some discussion elsewhere, I switched back to the native drupal comments.module in order to provide my users with the ability to comment on blog posts.

My main problem now? The comment count doesn't show up for a story on the front page. http://www.alleria.com . This page has a story called 'Passing of the Phoenix Father' (don't ask) and a user has commented on it. However the fact that there is a comment does NOT show up on the front page, for either logged in or anonymous users.

I KNOW this worked in a clean install of 4.6.6 at some point, it definitely worked in 4.5, and it is important that it works so that my users can see that they SHOULD comment. Any help?

I've looked in skinning, theming, comment settings, content settings, theme settings, everything. It seems that the comment count is produced in the $links variable, so I was wandering if this was changed somewhere else in vbDrupal to enable compatibility with vBdrupal?


Or should I just try running this script - http://drupal.org/node/43528

It also seems that there was an issue with comment updating back in 4.5


Help? :confused:

Caerydd
04-17-2006, 08:46 AM
I tried running that script, and it updated the comment counts, but no joy on the comment count appearing on the front page.

I looked at comment.module (drupal native) and I think this is the code that governs the appearance of comment counts in node teasers.

/**
* Implementation of hook_link().
*/
function comment_link($type, $node = 0, $main = 0) {
$links = array();

if ($type == 'node' && $node->comment) {

if ($main) {
// Main page: display the number of comments that have been posted.

if (user_access('access comments')) {
$all = comment_num_all($node->nid);
$new = comment_num_new($node->nid);

if ($all) {
$links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');

if ($new) {
$links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
if ($node->comment == 2) {
if (user_access('post comments')) {
$links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')));
}
else {
$links[] = theme('comment_post_forbidden');
}
}
}
}
}
else {
// Node page: add a "post comment" link if the user is allowed to
// post comments, if this node is not read-only, and if the comment form isn't already shown

if ($node->comment == 2 && variable_get('comment_form_location', 0) == 0) {
if (user_access('post comments')) {
$links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Share your thoughts and opinions related to this posting.')), NULL, 'comment');
}
else {
$links[] = theme('comment_post_forbidden');
}
}
}
}

In the database I can see drupal_comments and drupal_node_comment_statistics


// Main page: display the number of comments that have been posted.

if (user_access('access comments')) {
$all = comment_num_all($node->nid);
$new = comment_num_new($node->nid);

if ($all) {
$links[] = l(format_plural($all, '1 comment', '%count comments'), "node/$node->nid", array('title' => t('Jump to the first comment of this posting.')), NULL, 'comment');

if ($new) {
$links[] = l(format_plural($new, '1 new comment', '%count new comments'), "node/$node->nid", array('title' => t('Jump to the first new comment of this posting.')), NULL, 'new');
}
}
else {
if ($node->comment == 2) {
if (user_access('post comments')) {
$links[] = l(t('add new comment'), "comment/reply/$node->nid", array('title' => t('Add a new comment to this page.')));
}
else {
$links[] = theme('comment_post_forbidden');
}
}
}
}
}
else

This is from a clean comment.module I downloaded as part of 4.6.6 from the main drupal site.

Caerydd
04-17-2006, 09:07 AM
Okay, have any changes been made to comments.module-drupal in vbdrupal 1.3.3/1.3.2?

/**
* Updates the comment statistics for a given node. This should be called any
* time a comment is added, deleted, or updated.
*
* The following fields are contained in the node_comment_statistics table.
* - last_comment_timestamp: the timestamp of the last comment for this node or the node create stamp if no comments exist for the node.
* - last_comment_name: the name of the anonymous poster for the last comment
* - last_comment_uid: the uid of the poster for the last comment for this node or the node authors uid if no comments exists for the node.
* - comment_count: the total number of approved/published comments on this node.
*/
function _comment_update_node_statistics($nid) {
$count = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = 0', $nid));

// comments exist
if ($count > 0) {
$node = node_load(array('nid' => $nid));
$last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = 0 ORDER BY cid DESC', $nid, 0, 1));
db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? NULL : $last_reply->name, $last_reply->uid, $nid);
}

// no comments
else {
db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", 0, NULL, 0, 0, $nid);
}

is the bit governing comment statistics. *sighs* Erm, the only thing I can think of doing is just replacing the comment.module-drupal with the latest comment.module for Drupal 4.6.6 . Would that damage anything?

Help?

sifuhall
04-17-2006, 01:51 PM
AFAIK only Tamarian or possible El Muerte can answer this, but they are both very good about support questions such as this.

I have no idea.

Caerydd
04-18-2006, 06:07 AM
Thank Sifuhall :) I haven't seen any of them post for a while though :( But a new oddity has cropped up - blog comment counts show up fine, so I'm wondering if it just a problem for articles posted while vb comments were enabled.

I've got a new story on my front page now, so hopefully we'll see soon!