i'm facing a problem - i've got a view with exposed filter and exposed sorting
but i also have a custom sorting (draggableviews weight), which isn't and can't be made exposed.

what i need is to use draggableviews sort as default - before user applies exposed sort order. but whatever i've tried, only exposed sorting is respected.

i've tried setting $form_state['input']['sort_by']='weight' in the hook_form_alter but then the view throws an error with no results.

can someone please point me in the right direction. thanks.
ps: i also created an issue in the Views http://drupal.org/node/1813744

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iStryker’s picture

Status: Active » Closed (won't fix)

So you would need to add

'filter' => array(
'help' => t('filter out a weight(s)'),
'handler' => 'views_handler_filter_numeric',
)
to $data['draggableviews_structure']['weight'] in draggableviews.views.inc file

I do not see a use case for this so I'm closing it. Plus the values will be displayed incorrectly until #1901192: Row weight values range should be the same as what gets save to database is fixed.

If you are having trouble with expose filters. See Issue #1902536: How things work when you have one or more exposed filter

Cleaning up issue queue. Reopen if this is not the case.

iStryker’s picture

Patch attached. If anyone finds a use case for this and wants this committed, please comment.

Fernly’s picture

Issue summary: View changes
Status: Closed (won't fix) » Active

This seems like a very common situation...

Products are displayed in a custom order by choice (draggableViews) when the customer enters the web shop. The customer needs to be able to reorder the products by title, price, ... .
At the moment, the other sort criteria which are exposed are overruling the DraggableViews weight right at the page load. The DraggableViews weight becomes unused here.

I also don't see how the 'filter' patch in #1 end #2 fixes this problem, as it is a sorting issue.

I'll be looking for a solution and when I found one I'll post it over here.

Fernly’s picture

Status: Active » Fixed

I got it to work, but it's still not really a default option in the module. Also, I'm using one contextual filter "term id" in my example.

The trick is to make only the contextual filter count through the 'Prepare arguments with PHP code' option of the Draggableviews native weight sort:

PHP code to prepare arguments on the sorting display:

return array(0 => $arguments[0]);

All existing arguments can be found in $arguments. I only return a new array containing the contextual filter which is a taxonomy term in my case.

PHP code to prepare arguments on the actual front-end display:

if (count($_GET) == 1) {
  return array(0 => $arguments[0]);
}

$_GET gives 1 when there are no parameters in the URL. As soon as the user uses exposed filters, the altered array will not be returned and the draggableviews sorting will not be applied. The draggableviews sorting is only applied when the matching arguments are presented.

The draggableviews sorting is not exposed, but will be used as default sorting until other exposed filters are used.

A real solid solution is still welcome...

Status: Fixed » Closed (fixed)

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

markdc’s picture

Category: Support request » Feature request
Priority: Major » Normal

I vote to reopen this because I have a very practical use case for this feature.

I'm creating a task management application. I have a list of Tasks that users can sort by priority, due date, etc. Since they are also able to manually sort the Tasks with the help of this module, it would be expected that "Sort Manually" is an option in the Exposed Sort dropdown.

From a UX perspective, with no way to revert back to manual sorting, Draggable Views becomes unusable for this part of my project. I'll follow this issue and hope someone comes along with a fix. If I had time, I'd learn PHP and offer to help myself.

Otherwise thanks for this module. I can at least use it to sort simpler checklists within my Tasks.

mrchristophy’s picture

+1 I want to do this right now