Welcome Guest, Not a member yet? Register   Sign In
How do I work with all this data without making my URLs too long?


I basically have a section of my site where the items can be viewed depending on their country and city, and then the results can be sorted by data, number of views or whatever else.

I don't want to end up with URLs looking like this:

Because it's very linear and not flexible in case I needed to add something else in the future.

So, how could I overcome this limitation?

If it can't be overcome, then is there a way I can enable GET variables for this section (i.e: Controller) for my site?

Your help is much appreciated

Using GET makes an even longer string, or am i missing something?

Yea it would look long and ugly, but at least I'll get to add or remove variables without worrying about breaking old links.

You could have the page be:


Then add some UI elements on the page to select the country, city, and sort type. Use AJAX to query the data and generate the html. Then simply display the result.

mdowns solution is probably best, but if you dont want to use ajax you can always make your own "query string".

I did this for one of my projects. My uri segment looked like this:


This broke down to:



I don't see anything particularly wrong with this, actually. As long as you've thought it through and the organization makes sense, there shouldn't be a good reason not to do this unless you're delibeately planning to change it in the future. If it comes up that it *must* be changed, there are numerous ways to redirect to the new content (mod_rewrite, CI routing, or redirecting within the URL itself). Or you could use a redirection technique right in the beginning, by using links like:


[eluser]Colin Williams[/eluser]
Use the uri_to_assoc() method of the URI class to get key/value pairs from the URI

[eluser]Tom Glover[/eluser]
[quote author="Colin Williams" date="1218596863"]Use the uri_to_assoc() method of the URI class to get key/value pairs from the URI[/quote]

That could make it simpler at the expense of doubling the length of your url's

Theme © iAndrew 2016 - Forum software by © MyBB