Expose sorting field and sorting order so that users can sort views tables by table column data, say title, author or date.

CommentFileSizeAuthor
#10 sortable_teasers.module2.07 KBDave Cohen

Comments

merlinofchaos’s picture

You 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.

solipsist’s picture

Thanks! I didn't know. I'll try that.

drawk’s picture

It'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.

merlinofchaos’s picture

While 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'.

drawk’s picture

Ah, good thinking. That'll do just fine.

solipsist’s picture

How can I create them as tabs?

merlinofchaos’s picture

Status: Active » Fixed

Under 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.

solipsist’s picture

Great! Thanks for explaining and looking into this!

Anonymous’s picture

Status: Fixed » Closed (fixed)
Dave Cohen’s picture

StatusFileSize
new2.07 KB

I 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.

merlinofchaos’s picture

Hey, 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.

hickory’s picture

Status: Closed (fixed) » Active

I'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).

ultraBoy’s picture

Yes, i have the same situation as hickory. Tabs are also not ok if there are lots of fields.

Dave Cohen’s picture

hickory 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.

merlinofchaos’s picture

Status: Active » Needs review

Unless 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.

merlinofchaos’s picture

Status: Needs review » Postponed

OH a note: sortable_teasers might be good for the bonus pack, if people like it.

Rosamunda’s picture

Just tracking this issue :-)

webchick’s picture

Subscribing. Btw, the module seems to work fine in D5 by just creating an .info fie.

etherworks’s picture

I 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.

wolfderby’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

I'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!

chadchandler’s picture

Any news or work arounds to get exposed "Sorts"?! I can't believe it's not core :)

eikes’s picture

same 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.

merlinofchaos’s picture

Status: Postponed » Closed (duplicate)

This 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

socialnicheguru’s picture

i like the tab idea for the sort

aprium’s picture

You can use hook_views_pre_query() to alter the view and change the sort. Not the same as a nice GUI module though.

sbydrupal’s picture

Just 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 %.

Duplika’s picture

Suscribing.

Jordash’s picture

I 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.

TrinitySEM’s picture

Subscribe

solipsist’s picture

I 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

Hobbes-2’s picture

Subscribe

jsheffers’s picture

Using 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?

WeRockYourWeb.com’s picture

Same question - any progress on this for Drupal 6.x or 7.x?