Welcome Guest, Not a member yet? Register   Sign In
Organising my query strings/code
#1

[eluser]JamieBarton[/eluser]
Hi guys,

Having a bit of difficulty with this one..

I want to be able to go to url.com/events and see a list of all events, however, these can be changed and ordered by date of the event, or alphabetically..

I also want when you go to url.com/city-name, to show all the events that are happening in that city (each event has a event_city_name field), and then be able to organise this by date of event and alphabetically too.. Events can be sorted within their start and end time too..

I can't for the life of me get my head around how to organise this code.

I've thought maybe a bunch of $_GET's, and use query strings, however, even if I do use query strings, I don't know how to organise/start this code...

I originally had an event controller, with date and alphabetically methods inside, which then would have all the events then, but that way means a lot of code which will be duplicated, more queries too.

Surely there is an easier way to organise the code..

Hopefully someone can help me Smile

Would appreciate it very much! Smile
#2

[eluser]steelaz[/eluser]
You could use custom routing - http://ellislab.com/codeigniter/user-gui...uting.html and route url.com/city to url.com/events/city , although in my opinion url.com/events/city works just as well and provides better description for the page.
#3

[eluser]JamieBarton[/eluser]
Yeah I have that currently now too.

However, it would mean there would be some code duplication in the city and the other methods in the event controller.

Not sure if I should just make all parameters possible that I'll have in the URL and send them to the model, which would then if isset(), do a where statement...

Not sure if that's the best thing to do though....




Theme © iAndrew 2016 - Forum software by © MyBB