hollyvalero Posted October 26, 2020 Share Posted October 26, 2020 I have 2 templates: Legislation and Events Legislation template fields:billnum (eg 1234)billtype (eg SD, LD, LR)title (An Act to Whatever)clients - a page reference field. We start with legislation of interest to a specific user who has tagged clients by role for that search string...and sort them by committee $user_roles_string = $user->roles->find('name!=guest')->implode('|', 'name'); $bills = $pages->find("template=trackerplus, limit=600, client=$user_roles_string, sort=billscmte"); And for each bill, we list clients which is simple since we prequalified them and that field is in this template: foreach ($bill->client as $c) { echo "{$c->title}"; } On the Events template, we have a single page reference field that references the piece of legislation above, with a custom format label that brings in {billtype} {billnum} {title} billcalendarbillref When outputting events, again, I use the user roles string to get the batch. $user_roles_string = $user->roles->find('name!=guest')->implode('|', 'name'); $events = $pages->find("template=trackercalendarevent, client=$user_roles_string, sort=$cbdate2, limit=600, cbdate2>=today"); For each event I want to create a similar loop to list the clients, but I need to look up the legislation to find a match first - using just the prequalified group of events. // if there is a bill reference in the event item if ($event->billcalendarbillref->id) { // locate the legislation page that matches the billcalendarbillref, get the clients listed, and print them out. $items = $pages->find("template=trackerplus, title=$event->billcalendarbillref->title, limit=1"); foreach ($items->client as $c) { echo "{$c->title}"; } } This doesn't seem right...Not sure how to word the match between [template:trackerplus, title] and [template:calendar, billcalendarbillref] ... I thought maybe I should be using $items = $page->references(); but then got hopelessly confused... It's printing blank instead of an error which is a nice change of pace. ? What am I doing wrong? Link to comment Share on other sites More sharing options...
adrian Posted October 27, 2020 Share Posted October 27, 2020 I'll admit I haven't really read your post - sorry, but I think this might do what you want based on the topic titlehttps://processwire.com/api/ref/page/references/ Link to comment Share on other sites More sharing options...
hollyvalero Posted October 27, 2020 Author Share Posted October 27, 2020 22 minutes ago, adrian said: I'll admit I haven't really read your post - sorry, but I think this might do what you want based on the topic titlehttps://processwire.com/api/ref/page/references/ I’m looking for examples of how to use the page reference method. It seems like that’s the way to go. the page reference field is billcalendarbillref and it’s in the events records found. I need to match that field to the page title of legislation pages using the trackerplus template. 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