First, thanks for this wonderful module. I'm only beginning to understand, but I feel the power!

I was very confused, though, why my sorts are not applied to summary views. Here's code in _views_build_query():

  if (!$summary) {
    _views_view_build_sorts($query, $view);
    if (($view->page && ($view->page_type == 'list' || $view->page_type == 'table')) || 
      ($view->block && ($view->block_type == 'list' || $view->block_type == 'table'))) {
      _views_view_build_fields($query, $view);
    }
  }

As you see, sorts are added to the query only if its not a summary. I've tried changing to this:

  _views_view_build_sorts($query, $view);
  if (!$summary) {
    if (($view->page && ($view->page_type == 'list' || $view->page_type == 'table')) || 
      ($view->block && ($view->block_type == 'list' || $view->block_type == 'table'))) {
      _views_view_build_fields($query, $view);
    }
  }

In my quick test case, it worked as expected. Is there some reason the sort is not applied to summaries? I really think it should.

Thanks again.

Comments

merlinofchaos’s picture

Assigned: Unassigned » merlinofchaos

Oh hmm. This is an interesting conundrum.

I seem to recall that there are issues with sorts that are unrelated to the argument.

I don't remember any examples offhand, so I'll have to research and see why, but I recall strange results in some situations, so I ended up not putting in the sort criteria on summaries.

Dave Cohen’s picture

In my case, the sort is not related to the argument.

For instance, I have two views that filter only by node type, and have as arguement only node id. One sorts by node update time, the other by node title.

I have other views using argument to filter on other parameters, and I've added sort by node title.

My cases work using my patch above, but that's no guarantee it hasn't broken something else. Maybe its always safe to sort by node table fields? But in any case I feel that some ability to sort a summary is a must.

merlinofchaos’s picture

Status: Needs review » Needs work

This isn't forgotten, but this patch isn't how I want to do it.

Hopefully I can work on this issue this weekend.

merlinofchaos’s picture

Status: Needs work » Fixed

Ok, I have implemented this in a way which should work nicely across the board.

Permanently Undecided’s picture

Status: Fixed » Active

I did a checkout of the latest cvs version of the module and ran update.php, but in my case the sort still isn't applied in summary views. As sort criteria I have applied Node: Created Time Descending, and while it works great in page views, in summary views I still get a list ordered by Node: Created Time Ascending.

Thanks for this great module! :)

merlinofchaos’s picture

And unless you changed the argument default to "Summary, sorted by view" it won't. =)

Note that sorted by view is kind of silly -- you probably want 'sorted descending'. It'll make a nicer query.

Permanently Undecided’s picture

Status: Active » Fixed

You rock, man! Thank you so much!

Anonymous’s picture

Status: Fixed » Closed (fixed)