Jump to content

Getting all page field values from all grandchildren pages


Recommended Posts

Hi. Sorry if this has been covered someplace. I've got a Conventions site with Events pages. Among other things, each Event has a bunch of Topics and each Topic can have one or more Speakers. The same Speakers crop up again and again, so I've set up a page field for them. I'd like to display all the Speakers involved in the Event (basically, 'crawl' all the Topics and retrieve the Speakers, deal with duplicates and display them). And, the Topics are 'grandchildren' of the Events page (since I have other items on the Events page and want to keep things tidy?).

-- Jane Doe
-- John Smith
-- Bob Jones

-- Event One (Event Speakers: Jane Doe, Bob Jones, John Smith)
---- Topics
------- Topic 1 (Speakers: Jane Doe, Bob Jones) (assigned with a Multiple Page field from Speakers)
------- Topic 2	(Speakers: Bob Jones, John Smith)
-- Event Two

Once I found out how to access data on a grandchild page, I did used this selector: $speakers = $page->find('template=topic-page')->event_speakers(); 

That returned an array which when looped gave me this:


So, that's the IDs of the 3 speaker pages, with one duplicate, but I don't know what to do with this! Any ideas folks? Or is there another way that I'm missing? Thanks!

Link to comment
Share on other sites

Hi @strandoo Probably, you can handle it by using owner selector.


$speakers = $pages->find("template=speaker, speakers_field.owner.parent.parent.name=your-event-name");

Not tested, but should be someshing like this.
It's always a bit difficult to grasp, but try to paly with it a little.

  • Like 3
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

  • Recently Browsing   0 members

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