Marty Walker Posted October 8, 2012 Share Posted October 8, 2012 Hi, Is there a way to check if any comments have been posted on a page? I've tried this is no avail: <?php if($page->comments) { echo "something"; } Regards Marty Link to comment Share on other sites More sharing options...
Marty Walker Posted October 8, 2012 Author Share Posted October 8, 2012 I got it: <?php if($page->comments->count() > 0) { echo "something"; } Link to comment Share on other sites More sharing options...
MarcC Posted October 8, 2012 Share Posted October 8, 2012 Does count($page->comments) work too? Link to comment Share on other sites More sharing options...
Marty Walker Posted October 8, 2012 Author Share Posted October 8, 2012 Yes it does from what I can see. Link to comment Share on other sites More sharing options...
ryan Posted October 8, 2012 Share Posted October 8, 2012 Either count($page->comments); or $page->comments->count(); will work. You can also do it from selectors before a page is even loaded: $pages->find("comments.count>0"); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now