Jump to content

How to 'Custom PHP selector' current page


Recommended Posts


In the custom PHP selector code for a PageField how do I go about selecting pages that have a field that is the page that I am currently editing.

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
  if($event->object->name == 'field2') {
    $page = $event->arguments('page');
    $event->return = $event->pages->find('template=template1, field1=$page');

Link to comment
Share on other sites

Quick glance shows the first obvious problem is that you have a variable ($page) inside single quotes. You can either use double quotes, or concatenate.

find("template=template1, field1=$page");

find('template=template1, field1='.$page);


  • 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

  • Recently Browsing   0 members

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