Ralf Posted October 17, 2015 Posted October 17, 2015 Hello everybody, i try me just on a new project an "assignment list" for my association. I built years ago a first version with php and mysql but now i want to switch to Processwire My backend I have designed as follows: Home |- events (template events) | |- event | |- event (template event -> title, date, jobs (PageTable) | |- tasks |- groups |- places The PageTable "jobs" has the template "job" (title, select_task, job_begin, job_end, select_place, staff_needed, select_group & participants). And now I have tried using the following code to output the test data: $events = $pages->find('template=event, sort=date'); foreach($events as $event){ $content .= strftime('%d.%m.%Y', $event->getUnformatted('date')) ." $event->title<br />"; if($event->hasChildren > 0) { foreach($event->children as $child){ $content .= "<li>\$child->url: <a href='{$child->url}'>$child->url</a> // \$child->id: $child->id // \$child->select_task: $child->select_task // \$child->select_task->title: $child->select_task->title // \$child->select_place: $child->select_place //<br> \$child->staff_needed: $child->staff_needed // \$child->participants->count: $child->participants->count // \$child->job_begin: $child->job_begin // \$child->job_end: $child->job_end // </li><br><br>"; echo '<pre>'; print_r($child); echo '</pre>'; } } } the output you can see here: http://entwicklung.hungerberghexen.de/events/ My problem now is that with my code above i get not all values from the fields (it almost looks as if I would not be deep enough in the array?) e.g. "job_begin" & "job_end" -> work -- but for "select_task" i get only the ID ?! In advance thank you very much for any helpful hints cu Ralf
diogo Posted October 17, 2015 Posted October 17, 2015 Select_task seems to be a multiple page field (PageArray). Either you change it to single page (Page) in the settings, or you loop through it and output all the results foreach($child->select_task as $task)
Ralf Posted October 17, 2015 Author Posted October 17, 2015 Hi diogo, thanks for your fast answer. Sorry but "select_task" has in the settings -> Single page (Page) or boolean false when none selected?! And if i put your code behind the "print_r" foreach($child->select_task as $task){ $content .= $task->title; } i get this "Notice: Trying to get property of non-object..."
Ralf Posted October 17, 2015 Author Posted October 17, 2015 I found the mistake/ problem ... it were the curly braces // it doesn´t work $content .= "\$child->select_task->title: $child->select_task->title<br>"; // is working $content .= "\$child->select_task->title (with {}): {$child->select_task->title}<br>";
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