Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL segment constraints #6

Open
aboutwout opened this issue Nov 8, 2011 · 7 comments
Open

URL segment constraints #6

aboutwout opened this issue Nov 8, 2011 · 7 comments

Comments

@aboutwout
Copy link

Hi Doug,

Very nice extension and I can't wait to dig in (when I have a need for it), but there's one thing I'm missing compared to 'normal' routes in CI.

With CI routes you can do something like this:

`$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";``

Which basically says that the 2nd segment has to be a number. Is there any way to incorporate this in Freeway?

– Wouter

@averyvery
Copy link
Owner

That's an excellent idea. Are there other params like that? :string, I'm guessing?

@aboutwout
Copy link
Author

:string would be a bit too broad I guess, since practically anything can be a string... I'd go with :alpha

You can read up on CI's routing options here

@averyvery
Copy link
Owner

Thanks, this is helpful. Will look through their routing system to get a better idea about how Freeway can work.

@aboutwout
Copy link
Author

I did a little bit of thinking and since you need a segment name to use for the {freeway_{name}} variables, you'd have to add the contraints to it.

Something like this:

product/{{product_id:num}}/{{action:alpha}}

Or even incorporate a regex pattern:

`product/{{product_id:(\d+)}}``

– Wouter

@averyvery
Copy link
Owner

Interesting. My original thought would be that if segments had restrictions or special parameters like that, they would look more like:

{{product_id only="num" match="^299.*?$" from="cat_id" to="cat_name"}}

Seems more idiomatic to EE, and provides more flexibility for future features.

@mildlygeeky
Copy link

Adding this here because I think it also falls underneath URL segment constraints:

Currently the following route:
/testroute => /

will match a URL of /testroute, but it will also match /testroute2. Possibly regex anchors could be used to specify the beginning and end of the route to be matched? In my mind my route would end up looking like:

^/testroute/$ => /

@averyvery
Copy link
Owner

Weird — thanks for catching that oversight. Will make sure to anchor the segments between ^ and $.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants