Jump to content
maddmac

Passing URL parameter to Hook

Recommended Posts

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');
  } 
});

 

Share this post


Link to post
Share on other sites

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');
  } 
});

 

  • Like 2

Share this post


Link to post
Share on other sites

@Zeka Do you know if you can pass form variables from Formbuilder into this hook directly?

Share this post


Link to post
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...