• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I work with all this data without making my URLs too long?

#1
[eluser]KeyStroke[/eluser]
Hi,

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:
Quote:http://example.com/controller/function/c...t_by_date/

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

#2
[eluser]xwero[/eluser]
Using GET makes an even longer string, or am i missing something?
Quote:http://example.com/controller/function/?..._date=date

#3
[eluser]KeyStroke[/eluser]
Yea it would look long and ugly, but at least I'll get to add or remove variables without worrying about breaking old links.

#4
[eluser]mdowns[/eluser]
You could have the page be:

http://example.com/controller/function

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.

#5
[eluser]SpooF[/eluser]
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:

Code:
manufacturer.3-user.3-status.1

This broke down to:

Code:
manufacturer=3
user=2
status=1

#6
[eluser]eilrahc[/eluser]
http://example.com/controller/function/c...t_by_date/

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:

http://example.com/searchcity/12345

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

#8
[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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.