Jump to content

Passing URL parameter to Hook


maddmac
 Share

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

 

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