It would be very handy to be able to sort the summaries by their counts, placing the most tagged arguments first (I'm using term name for this example). Currently, you can only sort summaries ascending or descending. It's difficult when using large vocabularies, because you have to limit the display, but then it cuts them off alphabetically. Let's say we limit to four items.

So instead of:

Apple (2)
Berry (1)
Banana (1)
Cantaloupe (4)
.... with the rest cut off

It could display:
Orange (12)
Cherry (10)
Watermelon (9)
Fig (8)
.... with the less common terms cut off

Imagine the possibilities when using as an attachment. Similar to faceted search...
One little checkbox that says "sort by Count instead of Argument name" would do the trick.

Just a thought. Thanks a ton!

Comments

recrit’s picture

StatusFileSize
new2.09 KB
views version
6.x-2.x-dev, datestamp = 1248654545, packaged on 2009-07-27
file patched
views_handler_argument.inc,v 1.9 2009/06/26 00:23:42
description
this patch provides 2 more default action options:
  • Summary, sorted by number of records ascending
  • Summary, sorted by number of records descending
Code Changed
Added a function argument $by to default_summary and summary_sort. If $by is specified then that gets sent to query->add_orderby instead of name_alias. Refer to patch for full details.

Run the patch from /modules/views
This patch should also work on views 2.6 since no line numbers changed in views_handler_argument.inc from 2.6 to latest dev.

recrit’s picture

Version: 6.x-2.3 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new2.09 KB

this patch is still valid since views_handler_argument.inc has not changed in the latest dev. I am re-posting the patch and changing status to needs review. This works great to get a pareto view of taxonomy terms.

Mac Clemmens’s picture

Thank you!

thekayra’s picture

Works great. Thank you!

mnlund’s picture

Perfect! This should go in.

recrit’s picture

I agree it should go in. However, I had read some posts suggesting there was some work being done to make a more flexible aggregation with sum, count, etc. Hopefully that functionality is on the way.

maedi’s picture

Just what I was looking for, subscribing

merlinofchaos’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev
Status: Needs review » Fixed

Committed to the 3.x branch.

maedi’s picture

Just to clarify, does this feature work in combination with CCK Multigroup module? I'm getting some weird counts "(1865) or (1858)" for all of my "ingredients". Though the list is correctly ordered ascending or descending by these seemingly unrelated numbers.

OpsCon.kt’s picture

I have installed the patch and do not see such sort options. Am I looking in the wrong place?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

greggles’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Needs work
StatusFileSize
new164.98 KB

@Maedi in #9, can you do a preview of your view where you see that problem? I see a similar issue and found that it is because the query is not generated correctly. My query is:

"SELECT term_node.tid AS term_node_tid, term_data.name AS term_data_name,
node.nid AS num_records
FROM ..."

node.nid AS num_records is where my "seemingly unrelated numbers" came from.

@OpsCon.kt - you can use the 6.x-3.x-dev branch where this was applied if you are feeling adventurous, but it has some bugs. In general it should be in the overview of the settings for the Arguments. See attached screenshot for explanation.

greggles’s picture

Status: Needs work » Closed (fixed)

Talked with dereine in irc - #705668: Glossary view returns unexpected results. is the issue that fixed this problem for me.

@Maedi - maybe it will fix the problem you found as well.