dotnetic Posted July 21, 2023 Share Posted July 21, 2023 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 More sharing options...
bernhard Posted July 21, 2023 Share Posted July 21, 2023 /textilien(/{category})?(/{article})?/ 3 1 Link to comment Share on other sites More sharing options...
dotnetic Posted July 21, 2023 Author Share Posted July 21, 2023 Thx @bernhard So basically a simple regex. Facepalm that I did not thought of that myself ? Link to comment Share on other sites More sharing options...
flydev Posted July 21, 2023 Share Posted July 21, 2023 It's friday ? 2 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