Pulling content from selected template into frontend

I apologize for the title gore, here is my issue step by step :slight_smile:

I have a page with list of services, every service has an contact-person from team. This is how I managed the contact selection in service blueprint:

    width: 1/3
        type: fields
            label: Ansprechpartner
            type: multiselect
            options: query
            query: site.index.filterBy('template', 'in', ['team-member'])

As you see, you can select team members from different page and template. That works well.

Now in frontend, I’d like to display the associated team members into corresponding service page. Team members have usual fields like name, phone, mail etc…

What would be the best practice to pull the content from another page into service page (and how)?

You can convert your selected contacts into pages with the toPages() method

$contactPeople = $page->contact()->toPages(',');

foreach ($contactPeople as $contact) {
  echo $contact->whateverfieldhere();

You do know that you could use a pages field instead of the multiselect?

1 Like

Thanks! Kirby CMS is amazing, but the same applies to its support :smiling_face_with_three_hearts: