Jump to content

Recommended Posts

Posted

Hello,

I have the following selector on a pagereference field. It returns no output (an echo of the same selector returns output).

If I replace $suser with 41 it does work. I also tried to do this via ready.php. Also no output.

What is wrong?

image.thumb.png.3da8f535bf136a26e7d10e8765aa5c8d.png

Posted

You can't use API vars in the selector. You'd have to use the Custom PHP code to build the selectable pages.

Posted

thanks @Soma.

I also tried that with several version like this. No error but also no output. Namespace Processwire is added at the top of ready.php so I assumed $user would be useable here...

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'turtles_fed') {
        $event->return = $event->pages->find('template=turtle, created_users_id={$user}');
    }
});
Posted

Got it... with a lot of trail and error. $this->user.

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
    if($event->object->hasField == 'turtles_fed') {

        $event->return = $event->pages->find("template=turtle, created_users_id=$this->user");
    }
});
  • Like 1

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