XF 2.3 Can you use URL Params in Route filters, and if so, how would this be done?

Not out of the box, though I'd caution that removing the prefix ID from the URL entirely is brittle as it'll lead to dead links if the slug changes.

You could maybe create a (hidden) link node pointing to the prefix and set up a route filter for that, but it'll only redirect incoming requests.
 
Not out of the box, though I'd caution that removing the prefix ID from the URL entirely is brittle as it'll lead to dead links if the slug changes.
My use case was going to be using the "filters" with more "Friendly URLs", and that was the quickest example I could provide (with my case, it wouldn't change).

It would be used more like filtering "featured":
https://xenforo.com/community/forums/announcements/?featured=1
To:
https://xenforo.com/community/forums/announcements/featured
 
You could work around this with an add-on but it’s non-trivial.
It does look a lot cleaner, and if it could be done, it would make URLs look a lot more friendly, and possibly shorter.

Say an existing add on has ?some_var=some_text and you could create a filter for /var/text point to that... I suppose it has to be custom development to do, though (or making an add on to point to that if possible with another route).

Thanks!
 
It’s built-in and maps to the controller’s unread action. It’s a dynamic redirect and not for changing filters or orders of a list so kind of a different use case.

URLs map to controller actions universally though and are used all over the place.
 
It’s built-in and maps to the controller’s unread action. It’s a dynamic redirect and not for changing filters or orders of a list so kind of a different use case.

URLs map to controller actions universally though and are used all over the place.
Before I do some digging, is there a controller for filters? I'm wondering if there's still a possibility to do it with filters, if I can map a route to the controller with the filter appropriately set.
 
No, that's why they're query parameters. They all map to the same controller action, just with slightly different results.

You'd have to set up a custom controller and routes to it, map the corresponding request input manually, and reroute (not redirect) to the appropriate controller action, which is not entirely trivial (or really worthwhile IMO).
 
You'd have to set up a custom controller and routes to it, map the corresponding request input manually, and reroute (not redirect) to the appropriate controller action, which is not entirely trivial (or really worthwhile IMO).
Before that, is something like this in Development/Routes possible if you knew the exact params for that URL (if there's a way to capture them) as they should be unique?

1745384350055.webp
 
No, the router doesn't work like that. The link building callback is only for doing manual processing when creating link strings (ie. in templates) and is separate from routing itself.
 
  • Like
Reactions: frm
No, the router doesn't work like that. The link building callback is only for doing manual processing when creating link strings (ie. in templates) and is separate from routing itself.
Ok, I just thought there might be a "lazy man's" way of doing it.

I probably could've had something done by now with an add on that might've put me closer to getting what I want done with all this back and forth.

However, I appreciate you taking the time to answer this!
 
Back
Top Bottom