Need a helping hand with CI Routes - 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: Need a helping hand with CI Routes (/showthread.php?tid=6408) |
Need a helping hand with CI Routes - El Forum - 02-25-2008 [eluser]systemsos[/eluser] Howdy everyone, Just after a little bit of help with CI's routes. I have the following setup. I have a main controller, which handles dynamic menus and their content. So in my example I'm re-doing my website (it desperately needs my love and attention and not a 2 minute hack). I have the following things redirect to the default controller - which determines what section we're looking at, and what page of that section we're looking at. I have; /domains /domains/some-pages /hosting /hosting/some-pages /another-thing /another-thing/and-it's-pages Now I've been using routes for ['domains'] and pushing it back to my default controller, but that requires me to edit the routes.php file itself any time a new section is added. As far as CMS goes - I don't like that idea. I could use no route - and create a proper handling controller so that my site was mysite.com/site/domains - but I want to remove the /site/ all together. So now I've added a [':any'] and [':any/:any'] clause in my routes config. Which pushes "everything" back to the default controller. But I want "blog" for example to not be pushed there. So I add a ['blog'] = "blog"; to goto that controller instead. But then if I goto /blog/something it doesn't work. If I add ['blog/:any'] = "blog" - it just pushes it back to the default controller (and the index function) rather than where I would want it to go (it's normal function). This isn't a problem at the moment, but I just thought I would see if anyone else has done something similar to what I'm trying to do. Cheers for your thoughts [i]Edit: I have been trying to do something like $route['blog/:any'] = "blog/$2" but I don't actually know the proper setup for this. Need a helping hand with CI Routes - El Forum - 02-25-2008 [eluser]BravoAlpha[/eluser] [quote author="systemsos" date="1204020702"]Edit: I have been trying to do something like $route['blog/:any'] = "blog/$2" but I don't actually know the proper setup for this.[/quote] Code: $route['blog/(:any)'] = "blog/$1" Need a helping hand with CI Routes - El Forum - 02-26-2008 [eluser]systemsos[/eluser] God you're good. Thank you so much. I knew it would be something so simple. Brackets and $1 it was! Code: $route['admin'] = "admin"; For me, there would only ever be a handful of "static" sections, so it's far easier to default everything, and add my "static" entries (admin/blog/forums) rather than the other way around. Thank you again! |