Keyword

How to display comments on tags pages?

  • Roman Lipatov
  • Roman Lipatov's Avatar Topic Author
  • Offline
  • Premium Member
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
<?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
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Elite Member
More
8 years 5 months ago #153574 by JoomlaWorks Support Team
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
  • Roman Lipatov's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #153576 by Roman Lipatov
Replied by Roman Lipatov on topic How to display comments on tags pages?
Yes, I already use this code.
This is strange problem....

When I open category, K2 displays - No comments for item.




But when I open item page - it displays comments correct.



I use Jcomments.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #153615 by Krikor Boghossian
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.

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
  • Roman Lipatov's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #153692 by Roman Lipatov
Replied by Roman Lipatov on topic How to display comments on tags pages?
It seems problem not only in Jcomments.
Explain.

When I choose item menu Categories and set only 1 category - comments count in list displays ok.





But when I add more categories



comments counter displays - no comments

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #153701 by Krikor Boghossian
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
  • Roman Lipatov's Avatar Topic Author
  • Offline
  • Premium Member
More
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
<?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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #153706 by Krikor Boghossian
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.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum