Jump to content

selectable pages defined dynamically for Page field in repeater


valan
 Share

Recommended Posts

There is page/template with repeater field. Among others fields, there is Page field inside that repeater.

In admin, I need to generate a list of selectable pages for that Page filed dynamically, e.g. with help of custom PHP code.

Custom PHP code has access only to $page and $pages, but I also need to know current repeater item...

Is there any way to get current repeater item in custom PHP code (one you use to setup selectable pages)?

P.S. yes, I know that this could be done having pages instead of repeaters...)

Thanks!

Link to comment
Share on other sites

When you put a page field inside a repeater, the $page variable that field gets is the page you’re editing. Not the repeater page the field actually belongs to. Put another way, the $page variable will be the same as $repeateritem->getForPage(). What you want, however, is $repeateritem itself. Honestly, I doubt this is possible out of the box.

Like you said, if you used “real” pages in a PageTable field, you would edit those pages in a modal window. I. e. the $page variable supplied to the page field’s custom select code would be the current PageTable item.

I don’t want to be the guy who misses the point and answers “why don’t you just do something else”, but PageTables are so much cooler than repeaters anyway. Any specific problems that stop you from using those?

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