- Posts: 98
COMMUNITY FORUM
How to display comments on tags pages?
- Roman Lipatov
- Topic Author
- Offline
- Premium Member
Less
More
8 years 5 months ago - 8 years 5 months ago #153528
by Roman Lipatov
How to display comments on tags pages? was created by Roman Lipatov
Hi!
I need items on tags pages have commments count.
I added code
but it always displays "0 comments"...
Thanks.
I need items on tags pages have commments count.
I added code
<?php if(!empty($item->event->K2CommentsCounter)): ?>
<!-- K2 Plugins: K2CommentsCounter -->
<?php echo $item->event->K2CommentsCounter; ?>
<?php else: ?>
<?php if($item->numOfComments > 0): ?>
<a href="<?php echo $item->link; ?>#itemCommentsAnchor">
<?php echo $item->numOfComments; ?> <?php echo ($item->numOfComments>1) ? JText::_('K2_COMMENTS') : JText::_('K2_COMMENT'); ?>
</a>
<?php else: ?>
<a href="<?php echo $item->link; ?>#itemCommentsAnchor">
<?php echo JText::_('K2_BE_THE_FIRST_TO_COMMENT'); ?>
</a>
<?php endif; ?>
<?php endif; ?>
</li>
but it always displays "0 comments"...
Thanks.
Last edit: 8 years 5 months ago by Roman Lipatov.
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
- Offline
- Elite Member
Less
More
- Posts: 169
8 years 5 months ago #153574
by JoomlaWorks Support Team
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks Support Team on topic How to display comments on tags pages?
Add this code to your tag.php and specifically inside the loop that displays the K2 items
<?php echo $item->numOfComments; ?> <?php echo ($item->numOfComments>1) ? JText::_('K2_COMMENTS') : JText::_('K2_COMMENT'); ?>
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Roman Lipatov
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 98
8 years 5 months ago #153576
by Roman Lipatov
Replied by Roman Lipatov on topic How to display comments on tags pages?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 5 months ago #153615
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic How to display comments on tags pages?
Is JComments' code executed in the tag and category view?
Since this issue is related to JComments, I think you should let their devs know about this issue.
Since this issue is related to JComments, I think you should let their devs know about this issue.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Roman Lipatov
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 98
8 years 5 months ago #153692
by Roman Lipatov
Replied by Roman Lipatov on topic How to display comments on tags pages?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 5 months ago #153701
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic How to display comments on tags pages?
Does the same happen if you disable the Jcomments extension?
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Roman Lipatov
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 98
8 years 5 months ago - 8 years 5 months ago #153703
by Roman Lipatov
Replied by Roman Lipatov on topic How to display comments on tags pages?
Hi Krikor.
No, native K2 comments work fine.
Thank you for reply.
I find way, how to make Jcomments working on tags pages and multi categories pages.
For tag pages
For multi categories pages replace all $item->link with $this-item->link
No, native K2 comments work fine.
Thank you for reply.
I find way, how to make Jcomments working on tags pages and multi categories pages.
For tag pages
<?php
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_group='com_k2' and object_id='".$item->id."';";
$dbc->setQuery($sql);
$count = $dbc->loadResult();
if(!$count) {
echo '<a href="' . $item->link . '#itemCommentsAnchor">Add First Comment</a>';
} else {
echo '<a href="' . $item->link . '#itemCommentsAnchor">Comments (' . $count . ')</a>';
}
?>
For multi categories pages replace all $item->link with $this-item->link
Last edit: 8 years 5 months ago by Roman Lipatov.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 5 months ago #153706
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic How to display comments on tags pages?
Roman,
since this is related to JComments, you need to address this issue to the JComments devs.
since this is related to JComments, you need to address this issue to the JComments devs.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.