Hurme Posted December 28, 2017 Share Posted December 28, 2017 Hi, I've been building my first Processwire page and everything has gone alright until I needed to call fields from some child-pages. <?php foreach($pages->get("template=files") as $stuff) : ?> <?php print_r($stuff); ?> <?php endforeach; ?> I'm using this just to test if things are working. I have 3 pages using "files" template, but this code only returns the first one I made. Changing the order of the pages does not affect this. I'd rather not delete the first page to test if it affects anything, as it has a lot of content already. I'm sure I'm overlooking something really elementary here. I'm fairly experienced at building websites, but unfortunately not that experienced with PHP. Link to comment Share on other sites More sharing options...
Zeka Posted December 28, 2017 Share Posted December 28, 2017 Hi @Hurme $pages->get() returns Page or Null https://processwire.com/api/ref/pages/get/ I guess that what are you looking for is $pages->find() https://processwire.com/api/ref/pages/find/ 3 Link to comment Share on other sites More sharing options...
Hurme Posted December 28, 2017 Author Share Posted December 28, 2017 Hi, Alas these pages need to be hidden from find, but if get can only retrieve one page at a time, then that would explain why this isn't going anywhere. I'm guessing that they need to be put under a hidden parent and made visible themselves then? Link to comment Share on other sites More sharing options...
adrian Posted December 28, 2017 Share Posted December 28, 2017 7 minutes ago, Hurme said: Hi, Alas these pages need to be hidden from find, but if get can only retrieve one page at a time, then that would explain why this isn't going anywhere. I'm guessing that they need to be put under a hidden parent and made visible themselves then? Just do this: $pages->find("template=files, include=hidden"); 4 Link to comment Share on other sites More sharing options...
Hurme Posted December 29, 2017 Author Share Posted December 29, 2017 This topic can be marked as solved. The problem was simply me having wrong idea about how Get works. Thanks Adrian and Zeka. 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