Pagination filtering |
[eluser]fdog[/eluser]
I have a form that creates a pagination with a sql result. View: Code: <form action="http://localhost/index.php/results" method="post"> Controller: Code: $where = array( I use the $where to make the sql query. Pagination is created correctly, but I lose the filter values when the pag. links are clicked. Should I use sessions to keep the $where values or is there an easier way? Thanks.
[eluser]fdog[/eluser]
I solved it doing the following: Code: // save my $where array created from $_POST in session That way I keep the SQL query the same and don't mess with the pagination.
[eluser]skunkbad[/eluser]
Don't forget that you need to be able to turn off your filter to see the unfiltered results.
[eluser]Jondolar[/eluser]
I have thought about either using sessions or just making really long urls to support pagination and filters and sort orders and I'm still struggling with which way to go (and I'm running out of time). One benefit to using urls is that google (et. al.) will index more pages. For example, if you have a page with 10 records with several links that set filters then not only will google index the default page, but it will index the page with the filters set as well. It will also do it for your pages 2, 3, 4, etc. The problem is that you may get really complex and long urls such as: /controller/method/id/page/2/filter1/active/filter2/unassigned/sort/name Your way is cleaner, keep the filters in a session. However, no search engine will be able to set/use those settings to find the same content filtered.
[eluser]fdog[/eluser]
[quote author="Jondolar" date="1249692313"] The problem is that you may get really complex and long urls such as: /controller/method/id/page/2/filter1/active/filter2/unassigned/sort/name [/quote] My first try was doing exactly that. But it was too much trouble to make it work correctly. I ended up with a lot of bugs If you manage to get that working, please do share.
[eluser]Jondolar[/eluser]
Truth is, I think I'm going to do the same as you. Just not sure until I get there and start coding it.
[eluser]dgreenhouse[/eluser]
I really don't like the pagination class that comes with CI - it's very counter-intuitive and cumbersome. (urls look bad too) That said... I'm working on a pagination class (actually a function) that's fast and easy to work with. It's quickly becoming a very useful widget. After I've gotten it ready for use (soon), I'll post the code (with examples) for others to have a "look see." As far as the "goto page" urls are concerned, I've simplified it tremendously. Its output is very customizable like: The following depicts one of the links in the pagination widget output as it could be rendered. There's also a css file that comes with the code. Code: <a href="search/results/page/30">30</a> That's it! Return the results for page 30 – period! When the user navigates to a page, the controller code determines what the query offset is from the passed in var and the values retrieved from the session var. Easy peazy; lemon squeazy...
[eluser]dgreenhouse[/eluser]
I came across these screen casts while poking around on the web. http://www.weblee.co.uk/codeigniter/code...on-part-1/ http://www.weblee.co.uk/codeigniter/code...on-part-2/ http://www.weblee.co.uk/codeigniter/code...on-part-3/ http://www.weblee.co.uk/codeigniter/code...on-part-4/ Hope it helps...
[eluser]CARP[/eluser]
does anyone (maybe @fdog) know how much can be stored with set_userdata() ? I guess it is the most practical/quickest solution to this problem (I'm having a similar issue) |
Welcome Guest, Not a member yet? Register Sign In |