Jump to content

How to access first element of Page Reference field using a selector?


Clarity
 Share

Recommended Posts

Hello everyone!

I need to access first element of Page Reference (and generally first element of any collection) field using a selector. Something like $pages->find('page_reference.first=value'). I can't find how to do it in the documentation. Can you please advice me how to do it?

Link to comment
Share on other sites

Sorry if I was unclear, but it's not quite what I want. I need all pages with this Page Reference and with given in the selector value of the first element of this Page Reference, not the first page with this Page Reference.

Link to comment
Share on other sites

I'm not sure if that is possible with a selector, but a workaround would be to add a second hidden field to your template and create a hook that populates that field on save or saveReady. Then you can simple use a selector like this: $pages->find("template=yourtemplate, your_hidden_reference_field=$yourpage");

  • Thanks 1
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
 Share

  • Recently Browsing   0 members

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