I'm using Kirby CMS and I need to find out how many posts I have.
My posts are gotten with
$posts = $pages->find('posts')->children();
which echos an object with 10 items (links to the posts).
It is not an array so using count() returns 1.
How can I count the items in this object like I would with an array?
asked Jul 24, 2013 at 0:54
suryanaga
4,09212 gold badges39 silver badges49 bronze badges
-
3what does var_dump( $posts ); show?Nick Maroulis– Nick Maroulis2013年07月24日 00:55:32 +00:00Commented Jul 24, 2013 at 0:55
-
maybe you can conver it to an arrayJason Young– Jason Young2013年07月24日 00:55:44 +00:00Commented Jul 24, 2013 at 0:55
-
is it like a string? is there a delimiter between each posts?artsylar– artsylar2013年07月24日 00:57:53 +00:00Commented Jul 24, 2013 at 0:57
-
@marabutt var_dump shows a whole massive bunch of stuff, which I guess is all the data about all the posts.suryanaga– suryanaga2013年07月24日 01:10:57 +00:00Commented Jul 24, 2013 at 1:10
-
@sanjaypoyzer can you add it to your post?Nick Maroulis– Nick Maroulis2013年07月24日 01:12:00 +00:00Commented Jul 24, 2013 at 1:12
1 Answer 1
I have no experience with this library. But try this, it might work:
$count = $pages->find('posts')->children()->count();
answered Jul 24, 2013 at 1:23
federicot
12.3k19 gold badges71 silver badges111 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-php