Routing with dynamic Event ID in URL for event managment system |
[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
[eluser]PhilTem[/eluser]
From the CI user's guide: http://Remapping Function Calls
[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
[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
[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
[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-gui...s/uri.html
[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-gui...s/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 ?
[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 {
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |