Ralf Posted October 18, 2015 Share Posted October 18, 2015 Hi, i build a ""assignment list" and want to find some pages with the same event select_groups as the active user has roles. My setting: Home |- events (template events) | |- event | |- event (template event -> title, date, jobs (PageTable) | |- tasks |- places The PageTable "jobs" has the template "job" (title, select_task, job_begin, job_end, select_place, staff_needed, participants & select_group -> which is a PageArray with "Roles" as the Parent of selectable pages!) And now I have tried using the following code to output the test data: $events = $pages->find('template=event, jobs.select_group=1045, sort=date'); foreach($events as $event){ $content .= strftime('%d.%m.%Y', $event->getUnformatted('date')) ." $event->title<br />"; foreach($event->children as $child){ $content .= "<b>{$child->select_task->title}</b> ({$child->select_place->title})<br /> ({$child->job_begin} bis {$child->job_end})"; } } which 1045 is only a example id from one Role. BUT this Code ignore the select_group and output ALL events?! Questions: - goes the whole at all with one "find"? - how can i search after x user roles in y pages? (so I only display these events per user which he is allowed to see with his roles) How can I achieve that? Thanks Ralf Link to comment Share on other sites More sharing options...
kixe Posted October 18, 2015 Share Posted October 18, 2015 Could you post a more clear page tree. It looks like your jobs are child pages of an event foreach($event->children as $child) . Looking at your selector string I would expect a page tree more like this, which should return all events selected the job 'turn the light on'. /*Home |- events (template events) | |- event | |- event (template event -> title, date, jobs (PageTable of 'jobs') | |- tasks |- places |- jobs | |- 'turn the light on' (template=job, select_group = 1045) | |- 'clean staircase' ... Link to comment Share on other sites More sharing options...
Ralf Posted October 19, 2015 Author Share Posted October 19, 2015 Hi kixe, sure, I can try. /* Home | |- events (template: events -> field: title) | |- event (template: event -> fields: title, date, jobs (PageTable - with the template "job" for items) | | |- job A (template: job -> fields: title, select_task (Page), job_begin, job_end, select_place (Page), | | | staff_needed (Integer), select_group (Page - PageArray with "Roles" as the Parent of selectable pages), | | | participants (Page - PageArray with "Users" as the Parent of selectable pages)) | | |- job B | | |- job C | | |- job X | | |- job Y | | | |- event | |- job D | |- job E | |- job F | |- tasks (template: basic-page -> field: title) | |- task A (template: task -> field: title) | |- task B | |- places (template: basic-page -> field: title) | |- place A (template: place -> field: title) | |- place B sorry that i missed the jobs in the first page tree. Link to comment Share on other sites More sharing options...
kixe Posted October 19, 2015 Share Posted October 19, 2015 $events = $pages->find('template=event, children.select_group=1045, sort=date'); echo $events; This selector will find all pages with template 'event', where childpages have a field 'select_group' with the fieldvalue '1045'. Link to comment Share on other sites More sharing options...
Ralf Posted October 19, 2015 Author Share Posted October 19, 2015 Hi kixe, thanks - but hmm strange, the output is now nothing. But it should be 2 or 5 entries output - if i insert 1045 or 1041 as ID value. Have you else any idea? PS: a second challenge is to combine it with a query after "$user->roles" 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