There are a few ways to fix this. One way is to show a message (or, depending on permissions, a comment form) saying that there are no comments yet.

This patch simply checks $node->comment_count and displays the Talk tab only if there are comments. I consider this a bug fix.

Comments

avpaderno’s picture

Title: Only show the Talk tab when there are comments » Show the "talk" tab only when there are comments
Version: 5.x-1.2 » 5.x-1.3
Category: bug » feature
Status: Needs review » Needs work

The patch should be rolled up again for the last version of the module.

christefano’s picture

Status: Needs work » Needs review

It doesn't need to be rerolled. Please don't bump patches down to "needs work" unnecessarily.

Rush_iam’s picture

Can anyone port it to 6.x-1.5?
It is really useful patch

christefano’s picture

Rush_iam, the patch works against the D6 version as well as the D5 version. Please review it so that it might go into the next release.

Rush_iam’s picture

no :(
D6 version have different structure. I don't know where it should be applied because I can't find this string:
"if (talk_activated($node->type) && $node->nid && _talk_node_comment_value($node)) {"
help me please

christefano’s picture

StatusFileSize
new612 bytes

Oops, you're absolutely right. Sorry about that!

Try changing line 93 in the talk_nodeapi() function to this:

      if (talk_activated($node->type) && arg(0) == 'node' && $node->comment_count > 0 && !arg(2)) {

Attached is a patch that does that same thing.

Rush_iam’s picture

don't work too :(
This function controls 'Add comment' link at the bottom of node :|

christefano’s picture

Version: 5.x-1.3 » 6.x-1.5
Status: Needs review » Needs work

Sorry, Rush_iam. I don't have much time and I don't use this module anymore. Please feel free to work on this.

cwgordon7’s picture

This should no longer be a problem in 6.x-1.5...?

cwgordon7’s picture

I am unable to reproduce on the latest development version, so I'm going to mark this fixed... feel free to reopen with more details if it's still a problem.

Rush_iam’s picture

where is development version? 6.x-1.5? It shows "talk" tab always... Even if there is no any comments yet

cwgordon7’s picture

StatusFileSize
new781 bytes

Oh, sorry about that. Try this patch, applicable to the development branch, which should regenerate in the next ~6 hours.

cwgordon7’s picture

Status: Needs work » Needs review
cwgordon7’s picture

Status: Needs review » Fixed

Due to the lack of reviews, I'm making an executive decision that this patch should work. Thanks everyone!

marquardt’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Status: Fixed » Active

Hmm.

I guess I miss something; please let me know;-)

Via hook_nodeapi, the talk module overwrites the setting of the comment module and sets comments for the current node to disabled. According to the comment in the code, this prevents the comments of being displayed in the main view of the code. But because of the comments being disabled, an 'Add comments' link is also not displayed on the full node view, right?

If the talk page is disabled in case there are no comments, there's therefore no way to add a first comment to a node any more... Or how can a user get to the comment adding form?

cwgordon7’s picture

Status: Active » Needs review
StatusFileSize
new631 bytes

But because of the comments being disabled, an 'Add comments' link is also not displayed on the full node view, right?

No, the link should be displayed... oh I see the problem. Try this patch.

marquardt’s picture

No, sorry - that didn't help...

Looking into the generated html, it looks like that the links variable is printed, but it only contains an &nbsb (while without talk being enabled for that particular content type, it has a full link to the comment form).

cwgordon7’s picture

Hm. A few questions:

After applying the patch, did you clear Drupal's cache at admin/settings/performance?

Does the node you're testing on have its comment settings set to "Read/Write"?

Also, if you go into talk.module and put a var_dump($result); between lines 111 and 112, what's the result?

marquardt’s picture

Yes (clearing the cache) and yes (comments set to read/write). The var_dump is in the function talk_link() just before the result is returned, yes? The output (when going to a node which already has a comment) is

array(2) { ["comment_comments"]=>  array(2) { ["title"]=>  string(28) "Discussion page (1 comments)" 
                                              ["href"]=>  string(11) "node/1/talk" } 
           ["comment_add"]=>  array(2) { ["title"]=>  string(15) "Add new comment" 
                                         ["href"]=>  string(15) "comment/reply/1" }
}

while one without a comment gives

array(1) { ["comment_add"]=>  array(2) { ["title"]=>  string(15) "Add new comment" 
                                         ["href"]=>  string(15) "comment/reply/7" } 
} 

Formatting is mine...

cwgordon7’s picture

Right - so according to what you just posted, with the patch, the "add new comment" link IS always displayed... am I misunderstanding you here, or is the link just in the code and not making it to the display phase?

marquardt’s picture

Ahhh - you're right.

The problem is in recent version() of the Nitobe theme. It's node.tpl.php doesn't use the $links variable to create links at the end of the post, but does instead it's own logic - and that doesn't work well as soon as $links is modified. This is actually a problem for other modules as well - for example, the flag module adds a "Bookmark this" links which doesn't get printed either. I have raised an issue in the Nitobe queue.

Thanks for tracking this down - and my apologies for "hijacking" this issue with something that's not related with the talk module at all.

marquardt’s picture

A final update: The patch in #16 is required for the add comments link to appear.

cwgordon7’s picture

Status: Needs review » Fixed

This was committed a while ago, I don't know why I left this at needs review. :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.