opalepatrick Posted July 7, 2014 Share Posted July 7, 2014 For some reason this is not getting the content from the hidden child pages that I was hoping to see. $staff = $pages->get("/about-us/meet-the-team/, include=hidden")->children; ?> <div class="row firstrow lastrow"> <?php foreach($staff as $member){ echo $member->body; } As you can see, I am trying to publish hidden staff pages as content on a single page. Any clues as to what I am doing wrong? Link to comment Share on other sites More sharing options...
DaveP Posted July 7, 2014 Share Posted July 7, 2014 First line should be $staff = $pages->find("/about-us/meet-the-team/, include=hidden")->children; i.e. $pages->find rather than $pages->get when you are looking to return an array of pages. See http://cheatsheet.processwire.com/ Link to comment Share on other sites More sharing options...
opalepatrick Posted July 7, 2014 Author Share Posted July 7, 2014 Thanks a bunch DaveP. However, I am still not getting any content. Weird. I tried print_r($staff) and got nada as well. Is there a better way to try and spit out the array? I have checked the settings for the pages concerned and they seem fine and refer to their parent and children as I would expect. Baffled. Link to comment Share on other sites More sharing options...
MadeMyDay Posted July 7, 2014 Share Posted July 7, 2014 Should be: $pages->get("/about-us/meet-the-team/")->children("include=hidden"); since the children are hidden and not the parent. And also I prefer to get the parent by id since changing the page name would make your selector return nothing. For example if your team page has id 1020: $pages->get(1020)->children("include=hidden"); 5 Link to comment Share on other sites More sharing options...
Gayan Virajith Posted July 7, 2014 Share Posted July 7, 2014 How about trying `include=all`. $staff = $pages->find("/about-us/meet-the-team/, include=all")->children; Link to comment Share on other sites More sharing options...
MadeMyDay Posted July 7, 2014 Share Posted July 7, 2014 How about trying `include=all`. $staff = $pages->find("/about-us/meet-the-team/, include=all")->children; That would change nothing since the children() needs the selector. and include=all would also include unpublished children which I guess is not desired. 2 Link to comment Share on other sites More sharing options...
kongondo Posted July 7, 2014 Share Posted July 7, 2014 Shorter..... foreach ($pages->get('/about-us/meet-the-team/')->children as $child) { //do you stuff } Link to comment Share on other sites More sharing options...
MadeMyDay Posted July 7, 2014 Share Posted July 7, 2014 Shorter..... foreach ($pages->get('/about-us/meet-the-team/')->children as $child) { //do you stuff } Also no hidden pages in the result ;-) 1 Link to comment Share on other sites More sharing options...
opalepatrick Posted July 7, 2014 Author Share Posted July 7, 2014 Thanks a lot to you all. Processwire community is smashing. I used foreach ($pages->get("/about-us/meet-the-team/")->children("include=hidden") as $member) { in the end. Result! 1 Link to comment Share on other sites More sharing options...
kongondo Posted July 7, 2014 Share Posted July 7, 2014 Also no hidden pages in the result ;-) Ye of course ...it was just an example...but Patrick has now solved it 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