![]() |
Routing with dynamic Event ID in URL for event managment system - 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 with dynamic Event ID in URL for event managment system (/showthread.php?tid=54435) Pages:
1
2
|
Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]Saquib[/eluser] Hi Guys, I am developing an event management system using PHP Codeigniter and MySQL where I am not sure how i can solve below problems Problem 1 I want to make URL for back end like Quote:www.event-backend.com/event/EVENt_ID (for dashboard) and by changing the EVENT_ID i can open different event But in codeigniter how I can do it, second param will be a method of controller, i need it dynamic. what will be the routing ? Quote:Problem 2 I want to people can access event website (which is unique for every event) by typing Quote:www.somedomain.com Please help Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]PhilTem[/eluser] From the CI user's guide: http://Remapping Function Calls Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]Saquib[/eluser] Hi Phil, if you can post some code it will be very helpful I have a controller named event, which has other methods ->registration ->travel etc. I want to access these methods as follows www.event-backend.com/event/EVENt_ID/registration www.event-backend.com/event/EVENt_ID/travel I have gone through User guide in URI Routing section, but am not sure how i can access other methods in controller Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]TWP Marketing[/eluser] [quote author="Saquib" date="1347120616"]Hi Phil, if you can post some code it will be very helpful I have a controller named event, which has other methods ->registration ->travel etc. I want to access these methods as follows www.event-backend.com/event/EVENt_ID/registration www.event-backend.com/event/EVENt_ID/travel I have gone through User guide in URI Routing section, but am not sure how i can access other methods in controller[/quote] Using CI's URI sequence: /controller_name/method_name/param1 Code: www.event-backend.com/event/registration/EVENt_ID Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]Saquib[/eluser] [quote author="TWP Marketing" date="1347121909"][quote author="Saquib" date="1347120616"] Using CI's URI sequence: /controller_name/method_name/param1 Code: www.event-backend.com/event/registration/EVENt_ID I am not sure it is a good idea, because what happen when i need to paginate or pass other params. I need to keep EVENT_ID in methods place and then methods should come which will work for every event Code: www.event-backend.com/event/EVENT_ID/registration Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]TWP Marketing[/eluser] You can pass as many parameters as you wish: Code: /controller/method/param1/param2/param3/... Code: $param1 = $this->uri->segment(3); // note the segment numbers http://ellislab.com/codeigniter/user-guide/libraries/uri.html Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]Saquib[/eluser] [quote author="TWP Marketing" date="1347124284"]You can pass as many parameters as you wish: Code: /controller/method/param1/param2/param3/... Code: $param1 = $this->uri->segment(3); // note the segment numbers http://ellislab.com/codeigniter/user-guide/libraries/uri.html[/quote] I know it can be done using above pattern. But here we are missing that i wanted to have my EVENT_ID in place of controller methods place, How can we get below URL, is it possible ![]() Code: www.event-backend.com/event/EVENT_ID/registration I think it is possible with some routing but I can't figure out how ? Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]PhilTem[/eluser] Okay, some really quick and dirty code for the lazy: With Routing: Code: $route['event/(:any)/registration'] = 'event/registration/$1'; Code: class Event extends CI_Controller { Or, with _remap, there's no need for routing! Code: class Event extends CI_Controller { Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]TWP Marketing[/eluser] You could probably do it with routing, but I have not tried it and prefer to use MVC standard url's. I find your method to be reversed from normal and CI was not designed to reverse the position of the method and parameters. I think your URL makes more work for you and certainly bends the CI and MVC paradymes. Routing with dynamic Event ID in URL for event managment system - El Forum - 09-08-2012 [eluser]Saquib[/eluser] [quote author="PhilTem" date="1347126473"]Okay, some really quick and dirty code for the lazy: Or, with _remap, there's no need for routing! Code: class Event extends CI_Controller { Thanks Phil, I will go with that, what about second problem, someone can help. I don;t know how to point any domain to my app on a URL Quote:I want to people can access event website (which is unique for every event) by typing |