![]() |
Sorting AND filtering using uri segments - how?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Sorting AND filtering using uri segments - how?? (/showthread.php?tid=36319) |
Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]umbongo[/eluser] I currently have a table of data, which is sortable by any column. The uri is /sort-column/[asc/desc]/offset. works great. But I also want to be able to filter by any column (eg. Column 2 > 10, <100, whilst column 3 is ='text-string', etc etc.). How do i handle this with URI strings? (if it is possible whilst remaining sensible)?? Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]pbreit[/eluser] This is a clear case where query strings would be preferable but it's tricky to get them working properly in CI. Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]umbongo[/eluser] Thanks for the reply. What problems do i have to look out for / what problems does CI have with query strings? Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]natefons[/eluser] can you give us an example uri that you mean? im not really understanding everything you say. Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]Jeroen Brussich[/eluser] http://www.askaboutphp.com/58/codeigniter-mixing-segment-based-url-with-querystrings.html Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]umbongo[/eluser] OK i have changed to query strings and have the basic functionality working again. Now I am having a little trouble sorting out the links from the page. For example, to sort by ID, the ID table header is linked with /controller/?sort_by=[$id] (where [$id] is the sort_by value.) So that will sort by the ID column, but if something else is set then these will all be wiped out. I could preserve the previous information by appending ?sort_by=[$id] to uri_string() (if it worked in this case - in practice it wipes out ? and after) but that would give me the problem of getting uris such as /controller/?sort_by=[$id]&sort;_by=[$id] SO, is the only way to handle this to use a foreach loop checking if every parameter is set (and not equal to the perameter you are about to set) and then adding them into the uri when they are?? Is there a better way, as this seems massively convoluted??? Sorting AND filtering using uri segments - how?? - El Forum - 11-28-2010 [eluser]pbreit[/eluser] I'm not sure I understand what the problem would be. If someone clicks on the header link to sort, it should only contain one sort_by parameter. |