Jump to content

Help with the count function of the API


ZionBludd
 Share

Recommended Posts

Hi, I am wondering if someone can help me out with getting the count of the comments of a page? 

I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page, as below 

 

Screen Shot 2018-05-07 at 7.57.37 PM.png

 

The shops part that you see above is something similar to this 

<?php $set_page = $page->title;
$count = $pages->count("template=prices, title=$set_page");
echo $count;
?>

 

Link to comment
Share on other sites

6 hours ago, mattcohen said:

I am using Ryan's comments module as a reviews system for my site and would like to display the count of the comments per page

Assuming your comments field is called comments then you get the count like that :

$count = count($page->comments); 

or

$count = $page->comments->count();

 

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...