Hello,

Thank you for your module.

Is it possible to define two different views displays for sorting and to select which one should be applied programmatically ?

For instance in hook_views_query_alter() , choose the sorting display depending on some PHP logic...

I could find this key but it stays the same whatever the display used

$view->query->fields['draggableviews_structure_weight_coalesce']['field']= COALESCE(draggableviews_structure.weight, 2147483647)

thanks!

Comments

iStryker’s picture

The line of code you mention is to give new nodes, without an assigned weight, the largest weight possible, so they will show up at the bottom.

I do not know of any easy way of doing this. I am pretty sure it is possible. Anything is possible with Drupal. You may have to extend a class.

bendev’s picture

Ok,

I can see the sorting display of the views in the handler of the view to sort
I can modify it but it doesn't seem to work

hook _views_pre_view(&$view, &$display_id, &$args)
$view->display_handler->display->display_options['sorts']['weight']['draggableviews_setting_view']
hook_views_query_alter
 $view->display_handler->handlers['sort']['weight']->options['draggableviews_setting_view']

Is this a good place to look at ? any furhter idea how and when to modify handlers ?

thanks

bendev’s picture

Actually it works with

hook_views_query_alter
$view->display_handler->handlers['sort']['weight']->options['draggableviews_setting_view']

but I changed the arguments settings in the mean time to "Do not use any arguments". switching it back did the trick.

Now I just have to understand why it didn't work with the option to "Do not use any arguments"

thanks anyway