Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
iStryker CreditAttribution: iStryker commentedThe 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.
Comment #2
bendev CreditAttribution: bendev commentedOk,
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
Is this a good place to look at ? any furhter idea how and when to modify handlers ?
thanks
Comment #3
bendev CreditAttribution: bendev commentedActually 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