XF 2.0 URL route matching syntax question

jjff

Member
Hi everyone.

So I'm studying this page: https://xenforo.com/xf2-docs/dev/routing-basics/

And I see that :int<user_id,username> matches against your-name.1

I'm familiar with regex'es and have worked with them in several idioms but I don't recognize what's going on here.

user_id is before username in that <format spec>, whereas in the url the id is after a dot. Also nothing tells the system what username should be, it's definitely not an int.

Where can I find more about this matching format? Or is xenforo preprogrammed to match something-else.2342 for all int type parameters?

Thanks for your help on this.
 
The routing system doesn't use regexes. Routes are made of specific tokens that are parsed for both link building and route matching. Mostly you can look at examples through all of the core routes.

:int<user_id,username> means that it will match an integer parameter (which always uses the "." splitting approach). For link building, when an entity/array of data is passed in, it will pull from the user_id key to find the integer to use and the username key for the string ("friendly" name, which is only used in link building -- it's discarded when matching, if it's present).

Most of the other tokens use a generally similar approach.
 
The routing system doesn't use regexes. Routes are made of specific tokens that are parsed for both link building and route matching. Mostly you can look at examples through all of the core routes.

:int<user_id,username> means that it will match an integer parameter (which always uses the "." splitting approach). For link building, when an entity/array of data is passed in, it will pull from the user_id key to find the integer to use and the username key for the string ("friendly" name, which is only used in link building -- it's discarded when matching, if it's present).

Most of the other tokens use a generally similar approach.

Thanks, Mike. So it's a convention then. That URL snippet does not actually match the actual string, it's convened in XF that url slugs go somestring.integer always and the things inside < and > store those in this particular order under those names in the parameter bag.
 
Back
Top Bottom