Welcome Guest, Not a member yet? Register   Sign In
routing depth
#1

[eluser]reepher[/eluser]
I am working on an application that has a lot of location based data that needs to be organized. I created a location controller to be the jumping off point to drill down to this data. So a user can go to http://xyz.com/location and choose a state. That generates a new page at a url like http://xyz.com/location/Missouri where they can chose a city from the state Missouri. Then they would drill down to other categories based on the location(example: http://xyz.com/location/Missouri/Springfield/cars/bmw). This is where I realized routing doesn't scale they way I had thought.

routes:
Code:
$route['location/(:any)'] = "location/state/";
$route['location/(:any)/(:any)'] = "location/city";

(:any)/(:any) obviously doesn't work.
Is there a way to maintain the uri flow and continue to drill down into the granular data?
#2

[eluser]reepher[/eluser]
Ahh but this does work the way I expected it to. The most granular route must be at the top and filter its way down.
Code:
$route['location/(:any)/(:any)'] = "location/city";
$route['location/(:any)'] = "location/state/";
#3

[eluser]CroNiX[/eluser]
Yep, go from the most segments to the least, because as soon as it finds a match it will quit looking, and (:any) will match, well, everything (including segments).




Theme © iAndrew 2016 - Forum software by © MyBB