adrianmak Posted January 24, 2015 Share Posted January 24, 2015 For example, I find all pages with template name ABCDE $items = $this->pages->find("template=ABCDE"); foreach ($items as $item) { echo "<pre>" . var_dump($item) . "</pre>"; } } I var dump for each item, it has many other irrelevant data. Link to comment Share on other sites More sharing options...
kongondo Posted January 24, 2015 Share Posted January 24, 2015 'those many other irrelevant' data are actually very relevant ..Your find returns several Page objects (OK, could be one if only one hit found) each with lots of properties about the object. Because of this, var_dump() is not very helpful. What data exactly do you need from your find? Is that what you want to encode to json? Then you could do something like this... $myItems = array(); $items = $this->pages->find("template=ABCDE"); foreach ($items as $item) $myItems[] = array('id'=> $item->id, 'title' => $item->title); $myItemsJSON = json_encode($myItems);// 1 Link to comment Share on other sites More sharing options...
adrian Posted January 24, 2015 Share Posted January 24, 2015 You also might find this module by soma very useful: http://modules.processwire.com/modules/chrome-php-logger/ It logs lots of useful info to the console, including: "current page with all its fields and their value and field settings" I think this will be the easiest option for what I think you want. 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