routing depth - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: routing depth (/showthread.php?tid=49268) |
routing depth - El Forum - 02-13-2012 [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/"; (:any)/(:any) obviously doesn't work. Is there a way to maintain the uri flow and continue to drill down into the granular data? routing depth - El Forum - 02-13-2012 [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"; routing depth - El Forum - 02-13-2012 [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). |