maddmac Posted September 9, 2020 Share Posted September 9, 2020 Can you pass a URL parameter to a hook? If so what does that look like? This certainly isn't working or do I need use a before hook $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'myselect') { if(isset($_GET['temp'])) { $temp= $_GET['temp']; } else{ $temp = ''; } $event->return = $event->pages->find('template=$temp'); } }); Link to comment Share on other sites More sharing options...
Zeka Posted September 9, 2020 Share Posted September 9, 2020 https://processwire.com/docs/start/variables/input/ https://processwire.com/blog/posts/pw-3.0.125/ https://processwire.com/api/ref/wire-input/ $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'myselect') { $temp = $this->wire('input')->get('temp', 'text', 'fallback-template'); $event->return = $event->pages->find('template=$temp'); } }); 2 Link to comment Share on other sites More sharing options...
maddmac Posted September 9, 2020 Author Share Posted September 9, 2020 Thank @Zeka I just figured out a solution but your code is more elegant. Link to comment Share on other sites More sharing options...
maddmac Posted September 9, 2020 Author Share Posted September 9, 2020 @Zeka Do you know if you can pass form variables from Formbuilder into this hook directly? Link to comment Share on other sites More sharing options...
Zeka Posted September 9, 2020 Share Posted September 9, 2020 @maddmac Sorry, but no. I do not use FormBuilder. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now