Ticket #579 (closed enhancement: fixed)
K2 should not show 'Comments on this post' if there are none and comments are disabled
| Reported by: | michaeltwofish | Owned by: | |
|---|---|---|---|
| Priority: | trivial | Milestone: | 0.6 |
| Component: | Themes | Version: | 0.5 |
| Keywords: | K2, comments | Cc: |
Description
As per the summary. Many templates show this message, but it's inappropriate if there are no comments and comments are not enabled. The comment code should be wrapped in something like:
if ( !$post->info->comments_disabled && $post->comments->approved->count > 0 ) {
display comment stuff
}
Change History
comment:2 in reply to: ↑ 1 ; follow-ups: ↓ 3 ↓ 4 Changed 3 years ago by dmondark
Replying to msi:
but that means this has to be OK for Ali!
Why do you assume that I am not OK with any improvements?! Just because I am against cluttering themes with unnecessary code, does not mean that I am against your other improvements that you wrote and thankfully sharing with the community. I am just one community member. If more people are +1 for your sidebar additions, please go forward and apply it.
I can attach my complete K2 mod.
I can find at least 2 tickets holding k2 mods. I suggest creating a ticket that would hold all the mods that you have, and closing the others as a duplicate of the new ticket.
Otherwise, please link all the tickets so we know what to review and apply.
Thanks for your contributions to Habari
comment:3 in reply to: ↑ 2 Changed 3 years ago by msi
Replying to dmondark:
Replying to msi:
but that means this has to be OK for Ali!
Why do you assume that I am not OK with any improvements?!
No, I'm sorry. This came out wrong. I just wanted to say, I would like to have your OK because we discussed that in the group. I'm sorry, I wasn't saying you have a problem with me or my suggestions. Do not think that! OK?
comment:4 in reply to: ↑ 2 ; follow-up: ↓ 5 Changed 3 years ago by msi
Replying to dmondark:
I can find at least 2 tickets holding k2 mods. I suggest creating a ticket that would hold all the mods that you have, and closing the others as a duplicate of the new ticket.
Otherwise, please link all the tickets so we know what to review and apply.
I'm on it. I'm closing both tickets. What do you suggest? Shall I open a new ticket with my complete K2 patch? Or shall I attach it here?
comment:5 in reply to: ↑ 4 ; follow-up: ↓ 6 Changed 3 years ago by dmondark
Replying to msi:
Replying to dmondark:
I can find at least 2 tickets holding k2 mods. I suggest creating a ticket that would hold all the mods that you have, and closing the others as a duplicate of the new ticket.
Otherwise, please link all the tickets so we know what to review and apply.
I'm on it. I'm closing both tickets. What do you suggest? Shall I open a new ticket with my complete K2 patch? Or shall I attach it here?
I am with creating a new ticket for the complete K2 patch. And if that patch has a fix for this ticket implicitly, then you can close this one as 'duplicate'. Again, thanks for the constant contribution.
comment:6 in reply to: ↑ 5 Changed 3 years ago by msi
Replying to dmondark:
And if that patch has a fix for this ticket implicitly, then you can close this one as 'duplicate'.
No, it does not. Michael wants to hide the whole thing while I just disabled the output for pages.
Again, thanks for the constant contribution.
Don't mention it all the time. ;-) I'm having fun. Anyway, thanks.

Actually, I use this in my K2 modification for pages. As you wrote, many themes display "0 Comments" while the comments are disabled. My code (without the "is it a page?" check) looks like this
and is placed directly after the "Do not load" message in "comments.php". I also use this function
public function theme_post_comments_link( $theme, $post, $zero = "No Comments", $one = "%s Comment", $more = "%s Comments", $closed = "Closed" ) { if ( !isset( $post ) ) return ""; if ( $post->info->comments_disabled ) return $closed; $output = "<a href='" . $post->permalink . "#comments' title='" . _t('Comments on this post') . "'>"; $c = $post->comments->approved->count; switch ( $c ) { case '0': $output .= $zero; break; case '1': $output .= str_replace( '%s', '1', $one ); break; default: $output .= str_replace( '%s', $c, $more ); } $output .= "</a>"; return $output; }in "theme.php" to display the proper message about the comments
<span class="commentslink"><?php $theme->post_comments_link( $post, _t('No Comments'), _t('%s Comment'), _t('%s Comments'), _t('Closed') ); ?></span>Maybe you can give it a try. Or if you want (but that means this has to be OK for Ali!) I can attach my complete K2 mod. And you can trust me. I removed the sidebar stuff with the latest post, & comments etc.