Jump to content

Can't get $page->children() to work


joe_ma
 Share

Recommended Posts

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

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. :)

  • Like 4
Link to comment
Share on other sites

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.

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...