joe_ma Posted January 19, 2016 Share Posted January 19, 2016 Hello I try to generate a table of persons in template. All the persons are children of a page with this template. The childrens template contains these fields: - title (name of the person) - funktion (textfield) - email - vorstand (checkbox) - org_kom (checkbox) My code to generate the table looks like this: $vorstand = $page->children("vorstand=1, sort=sort"); $content .= "<table border='' class='whoiswho'>"; foreach ($vorstand as $v){ $content .= "<tr><td>{$v->title}</td><td>{$v->funktion}</td><td>{$v->email}</td></tr>"; } $content .= "</table>"; All I get in the output is: <table border='' class='whoiswho'></table> I am not able to see where I went wrong. Link to comment Share on other sites More sharing options...
DaveP Posted January 19, 2016 Share Posted January 19, 2016 Firstly, try adding echo $vorstand->count(); after your first line. That will tell you if there is anything to loop through with your foreach(). 1 Link to comment Share on other sites More sharing options...
joe_ma Posted January 19, 2016 Author Share Posted January 19, 2016 Output: 0 (zero) But several of these pages have the checkbox checked. Link to comment Share on other sites More sharing options...
DaveP Posted January 19, 2016 Share Posted January 19, 2016 Ok, so there's a problem with the selector. Standard kind of debugging process - try this: $vorstand = $page->children(); then $vorstand = $page->children("vorstand=1"); (You might not need sort=sort) Hang on, just thought of something! Take the space out of your selector. $vorstand = $page->children("vorstand=1,sort=sort"); You never know. 4 Link to comment Share on other sites More sharing options...
joe_ma Posted January 19, 2016 Author Share Posted January 19, 2016 Hmm, I think I tried this before … but don't know for sure. Anyway: $vorstand = $page->children(); echo $vorstand->count(); Doesn't change anything. Echoes "0". Ehm … the subpages are all hidden. Could this be the reason? Edit: YES! That IS the reason. Is there a way to list hidden pages? Edit 2: Yes, there is: use "include=hidden" as a selector. 2 Link to comment Share on other sites More sharing options...
justb3a Posted January 19, 2016 Share Posted January 19, 2016 Have a look here. include=hidden $vorstand = $page->children("vorstand=1,include=hidden,sort=sort"); 4 Link to comment Share on other sites More sharing options...
joe_ma Posted January 19, 2016 Author Share Posted January 19, 2016 Thanks a lot, justb3a. It seems I found out about that in the minute you posted your answer. 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