Jump to content

[solved] multiple URL hooks with named arguments not working


dotnetic
 Share

Recommended Posts

I have this URL hook (in an autoload module, but the same occurs if I use it in ready.php) and want to use named arguments, capturing the category and an article, like described in ProcessWire 3.0.173 core updates: New URL hooks:

 $this->wire->addHook("/textilien/{category}/{article}/", function ($event) {
  bd($event->category);
  bd($event->article);
});

The hook only works if the url looks like https://mysite.com/textilien/hoodies/myarticle.
It does not work if the URL is only https://mysite.com/textilien/hoodies/ or https://mysite.com/textilien/.

Is it possible to make the category and article optional? Or do I have to create a URL hook for every of these possibilities (what I did for now).

Link to comment
Share on other sites

  • dotnetic changed the title to multiple URL hooks with named arguments not working
  • dotnetic changed the title to [solved] multiple URL hooks with named arguments not working

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