Welcome Guest, Not a member yet? Register   Sign In
Creating query result filters dynamically
#1

[eluser]lexusgs430[/eluser]
Hi,

Im trying to create a query filter system in codeigniter. Basically, within a particular query, Id like to be able to send a list of values returned by the main query (working with items for sale on different sites, so for instance, price, and website), output them to my sidebar, and then be able to drill down the results via the values in the sidebar. (thefind.com is a great example on what im trying to do).

Ive been trying to wrap my head around exactly how to do this all day, but no luck. If anyone could push me in the right direction it would be much appreciated. P.S. im using DMZ datamapper object oriented code igniter extension library, so I figure that might help to make it easier?
#2

[eluser]n0xie[/eluser]
Can you explain in more detail what you are trying to do? A link to thefind doesn't really help because I have no idea what part of the site you're trying to emulate.
#3

[eluser]lexusgs430[/eluser]
Ok so when you do a search on thefind, it brings up a list of filterable options on the right side of the page, allowing you to drill down within the search results. This is what Im having trouble figuring out how to do. So for example, I have table called items. For each item, there is one site that the item is listed on. But within a results page, there may be many items from the same site returned. So, Im trying to figure out how I would get the distinct values of the sites which were returned from the query (in my model), and then from that query run another query to create the filter options. In addition, I need to be able to add additional options to the original query, in the event that the filters are being selected by the user. Does that make sense?
#4

[eluser]n0xie[/eluser]
What I'm seeing is that it shows a resultset based on a query. You have several 'filtering' options on the right. Whenever you activate one of those, you send an ajax request to a controller, and adjust your query to the database based on the filter. Then send the 'filtered' resultset back, and with a little javascript you replace the existing items with the new resultset.

You should first create the appropriate models/queries to do it without the ajax effect. Just a simple form with some filters. Press submit and it returns a filtered resultset. Once you have everything working, read up on ajax, add an ajax layer on top to do the requests asynch, giving the 'feeling' of real time filtering.

It's not that difficult to implement, just a bit of work.
#5

[eluser]martynrlee[/eluser]
This sounds like exactly the functionality I am working on at the moment, does anyone have any examples of this sort of thing working?

Or perhaps some useful tutorials for dynamically filtering results using codeigniter?

All help most appreciated.

Martyn.
#6

[eluser]bretticus[/eluser]
[quote author="martynrlee" date="1280954567"]...does anyone have any examples of this sort of thing working?

Or perhaps some useful tutorials for dynamically filtering results using codeigniter?[/quote]

Go look for Nettuts author Jeffrey Way's tutorial on jquery and ajax (the jquery load method in particular.) As n0xie says, this is calling the same query multiple times with parameters to filter by. The "magic" occurs when the checkboxes are checked and javascript calls the same url to generate the results after submitting a new value to filter by (from the checkboxes.) And yes, it is a bit of javascript work but jquery simplifies this. In fact, load() makes it almost trivial.

Good luck!




Theme © iAndrew 2016 - Forum software by © MyBB