Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I have two types of functionality on a page that is listing tracks.php

1. sorting tracks - using this method https://www.couchcms.com/docs/advanced-tutorial/list-view.html
2. filtering tracks by tag - using this method https://www.couchcms.com/forum/viewtopic.php?f=2&t=9243&p=19515 - the tags are set up as a relation to tracks.

Both the sorting and the filtering are using querystrings and I can get the sorting to work and the filtering to work separately. But what I wish to do is to allow the sorting of filtered tracks. I guess it would go something like this:

1. visitor clicks on keyword 'cinematic' - a list of all tracks tagged with 'cinematic' are displayed
2. visitor wants these sorted by title - clicks on sort and the filtered list is sorted

THis mockup may help to make it clear:
filtering and sorting.gif
filtering and sorting.gif (19.36 KiB) Viewed 1420 times


I've tried various methods to achieve a URL something like this: website.com/tracks.php?tag=cinematic&sort=title

I've come up against a brick wall .... heeeeelp?!
Hi,

I'm sure it could be done with couch only.
If I understand it right the complete list is loaded on the page and after that you want to filter and/or sort the list.
Just to hand a quick fix http://listjs.com/ I use if run into a problem like this.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
thanks Tomarnst - that looks like a very useful script, I've not come across it. I may well end up using it as the Couch technique eludes me!
@potato, what seems to be happening is this -
both the filters (sort and keyword) rely upon the presence of their respective querystring parameters.
So, suppose, you choose to sort the listing in a particular way, the 'sort' parameter appears in the querystring and the list is accordingly sorted. Now, suppose you choose one of the composers - the link being clicked will only have the parameter related to the composer i.e. the 'sort' is no longer there.

This results in the list being filtered by the chosen composer losing the previously selected sorting order.

The solution would be to use both sort and composer parameters in the links of both composers and sorting (at present they'd only be having their own).

Please use the <cms:gpc> tag to get the current values of the parameters and then append them ti the page's link using <cms:add_querystring> tag (the 'advanced tutorial does this for only one parameter).

Try it out and please let me know if this helps.
thank you, got back to this and after a bit of wrangling with " and ' I've managed to get 2 parameters!
5 posts Page 1 of 1