![]() |
Time for URL's YAY! - 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: Time for URL's YAY! (/showthread.php?tid=18060) |
Time for URL's YAY! - El Forum - 04-24-2009 [eluser]Michael Nielsen[/eluser] Hi, so I'm a newbie at PHP and CI, please bare with me. It's it possible to have the following URL: Code: index.php/support/ticket/reply/758593 (758593 been the ticket ID) or is it only possible to have 3 segments Code: index.php/ticket/reply/758593 Time for URL's YAY! - El Forum - 04-24-2009 [eluser]xwero[/eluser] You can have any number of segments Time for URL's YAY! - El Forum - 04-24-2009 [eluser]warrennz[/eluser] Depending on what you want to do you can have as many segments as you want. If you want to customize the URI segments differently to the standard /controller/method/var1/var2.. you'll need to define URI routing routes in config/routes.php Assuming you have a controller called ticket, with a method called reply, that takes a variable (the id) you can add this to your URI routing file Code: $route['support/ticket/reply/:num'] = 'ticket/reply/$1'; :num means it will accept only numbers. If you tried to access site.com/index.php/support/ticket/reply/random_string CI would return an error or a 404 not found. Read up on CI URI routing to get more familiar with replacements etc. ![]() Time for URL's YAY! - El Forum - 04-24-2009 [eluser]Phil Sturgeon[/eluser] Making a guess here it looks like using a controller sub-directory might be what you are looking for. Or possibly search for Matchbox for a more modular approach. Using Matchbox you could group all support controllers, models and views into one folder, instead of them all being split across your application. Routes are a good option too. Time for URL's YAY! - El Forum - 04-24-2009 [eluser]Michael Nielsen[/eluser] Thanks guys. Exactly what I was looking for! |