Expose sorting field and sorting order so that users can sort views tables by table column data, say title, author or date.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | sortable_teasers.module | 2.07 KB | Dave Cohen |
Expose sorting field and sorting order so that users can sort views tables by table column data, say title, author or date.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | sortable_teasers.module | 2.07 KB | Dave Cohen |
Comments
Comment #1
merlinofchaos commentedYou can already get that kind of thing via table sorting. I suppose it'd be nice to have that kind of functionality outside of tables, but it hasn't been a huge priority because of that.
Comment #2
solipsist commentedThanks! I didn't know. I'll try that.
Comment #3
drawk commentedIt's something I'd like to see outside of the table view.
For example, I'm using the Views bonus pack and a three column view. It would be nice to be able to expose the sort for creation date to be able to choose between oldest first and newest first.
Comment #4
merlinofchaos commentedWhile this is not as ideal as exposing the sort, what i usually do is use multiple views, and create them as tabs. The default might be, 'newest first' and the next tab my be 'oldest first'. And may a 'by alpha'.
Comment #5
drawk commentedAh, good thinking. That'll do just fine.
Comment #6
solipsist commentedHow can I create them as tabs?
Comment #7
merlinofchaos commentedUnder the Page section, open up the Menu section. Select provide menu, and provide menu as tab. At least one of the views providing a tab must be set default.
For example, if I have three views under 'foo/bar' I could do this:
URL: foo/bar/newest -- set as tab, set as default tab
URL: foo/bar/alpha -- set as tab
URL: foo/bar/oldest -- set as tab
Marking this fixed -- tabs covers most of the necessary sort options, even though it's possibly a little more difficult than if they were exposed, but the exposed filter code is kind of a pita.
Comment #8
solipsist commentedGreat! Thanks for explaining and looking into this!
Comment #9
(not verified) commentedComment #10
Dave Cohen commentedI was interested in making a sortable list of teasers, the approach I took was to create a new type of view which does some special stuff in the theme function. It uses the view's fields for sorting, while displaying the nodes as teasers, not rows in a table. I attach it here in case anyone wants to take it and run with it. Perhaps it could be made worthy of inclusion in views_bonus.
Comment #11
merlinofchaos commentedHey, totally. You are hereby granted commit access to the bonus pack. Please to be having fun with it! Be sure to update the README and if you have good ideas/are interested in expanding it a bit so it has more inline help for each of the plugins, that'd be welcome.
Comment #12
hickory commentedI'd really like to have the sort criteria exposed, and perhaps passed in through a query variable. I'm trying to make a view sortable, but it's already using tabs to navigate through categories, so I can't use the 'different views in tabs' idea (also that would mean configuring multiple views, which is a hassle).
Comment #13
ultraBoy commentedYes, i have the same situation as hickory. Tabs are also not ok if there are lots of fields.
Comment #14
Dave Cohen commentedhickory and ultraboy: have you tried sortable_teasers (see #10)???
I'm not sure if you're saying it doesn't work, or whether you have not tried it.
Comment #15
merlinofchaos commentedUnless someone else writes it, this is unlikely to be a feature in the 4.7 release. The exposed filters are pretty complex, and exposed sort criteria is likely to add a similar layer of complexity.
That said it's an interesting feature and may well make it into Views 2 but that will be for Drupal 5 only, and I wouldn't expect it for at least a few months.
Comment #16
merlinofchaos commentedOH a note: sortable_teasers might be good for the bonus pack, if people like it.
Comment #17
Rosamunda commentedJust tracking this issue :-)
Comment #18
webchickSubscribing. Btw, the module seems to work fine in D5 by just creating an .info fie.
Comment #19
etherworks commentedI tried using the sortable_teasers in 5.0 and created a .info file - didn't work for me, generated an error.
This would be a much appreciated addition to a views bonus back (exposed sort criteria) - would like viewers on my site to be able to sort by highest rated or recently added - table view doesn't work as its video and I need teasers.
Comment #20
wolfderby commentedI'd like to see this for 5.x
I'm trying to set up an ecommerce store and would like to sort the products by price high to low, low to high, brand, and title. I can get close to this using a table view, but I'm not sure if I can theme the single product rows of a table into 3 or 4 products per row.
If I could expose a sort filter for price (high to low and low to high) as well as for brand and title, I could just use a grid view and be done with it. :D
I've also expressed my specific need more thoroughly here http://drupal.org/node/150996
thanks to merlinofchaos and others for the great views module!
Comment #21
chadchandler commentedAny news or work arounds to get exposed "Sorts"?! I can't believe it's not core :)
Comment #22
eikes commentedsame here, it'd be so sweet! any suggestions?
the error i get is;
* warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\includes\tablesort.inc on line 149.
* warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\includes\tablesort.inc on line 187.
* warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\sites\default\modules\views_bonus\sortable_teasers.module on line 35.
Comment #23
merlinofchaos commentedThis is never happening for Views 1. It will show up for Views 2 but not until after the 2.0 release.
http://drupal.org/node/228510
Comment #24
socialnicheguru commentedi like the tab idea for the sort
Comment #25
aprium commentedYou can use hook_views_pre_query() to alter the view and change the sort. Not the same as a nice GUI module though.
Comment #26
sbydrupal commentedJust to add, tabs instead of exposed sorting, does not cover the issue, such as the default Taxonomy/term/tid view that comes with Views 2, which has page path containing % and you can not
set menu for paths with %.
Comment #27
Duplika commentedSuscribing.
Comment #28
Jordash commentedI tried the Menu Tab suggestion and I don't see the tabs showing up? I think it is a template issue because I programmed my template from scratch and might be missing the required Template Tag (which one do you think it would be). Right now I add links to the different URLS of the different sorting criteria pages but it would be nice if it was more automatic.
Comment #29
TrinitySEM commentedSubscribe
Comment #30
solipsist commentedI just released a module that works around this problem by exposing the displays of a view as AJAX tabs. Since a display can have a number of settings, one of them being sort order, it allows you to expose sorting and a lot more as well.
http://drupal.org/project/viewsdisplaytabs
Comment #31
Hobbes-2 commentedSubscribe
Comment #32
jsheffers commentedUsing a table or Views Display Tabs are a few ways to get around this problem, but I think sorting should be possible through exposing the sorting criteria outside of these two options.
Anyone have any progress with this?
Comment #33
WeRockYourWeb.com commentedSame question - any progress on this for Drupal 6.x or 7.x?