Currently, the node title is the only part of the node content that is displayed when ordering nodes with Nodequeue.

If the nodequeue ordering interface was a Views style plugin, then people could display any Views-support field from the nodes being ordered.

This would be a great way to create image galleries, and open up possibilities for new ways of using Nodequeue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ezra-g’s picture

Just want to note that features in the following issues could be implemented with this feature:

#371695: Thumbnails from Image module show up in nodequeue
#299111: Display CCK fields while manipulating a queue
#340800: SmartQueue for Views

xjm’s picture

Tracking.

EndEd’s picture

+1

MamaGubs’s picture

+1

g76’s picture

+1

beeradb’s picture

Status: Needs review » Needs work
FileSize
4.65 KB

Here's a tar of a submodule I've written to handle this. This still needs a bit of work to be commitable, but I think it's a strong start. This is particularly well suited for gallery needs, i.e. reordering a video or image gallery which is contained in a nodequeue.

After installing the module, here are the steps you'll need to go through to get a working view.

To create a draggable view:

  • Create a node view of the style "Draggable Nodequeues (list style)"
  • Add a relationship for nodequeue. Filter by the specific queue you want
  • Add an argument for subqueue reference. In my case I'm using http://drupal.org/project/smartqueue_users to create my subqueues, but do whatever makes sense to filter the view by one (and only one) subqueue.
  • Add whatever fields you want. In addition to your own fields, you'll need (queue) Nodequeue: Position and (queue) Nodequeue: Subqueue ID. The display style needs position so it can reorder properly, and subqueue ID so it knows what is it reordering.
  • Configure the display and let the display style know which fields are your order field and subqueue id fields. Auto submit is not yet implemented.
  • Use (queue) Nodequeue: Position as your order by field.

Add a page display, and get crazy with some reordering madness. As I said above, my use case is definitely dragging around images, so if you try it with other fields and get less desirable results, let me know.

Some things which need to be improved:

  • The javascript needs some work. In particular, it needs to be refactored to allow for multiple of these on the same page. I've already started namespacing the views in the Drupal.settings array.
  • The javascript needs to be updated to correctly use the start_at variable that's being set in Drupal.settings. Currently it doesn't do anything with offsets (think paged views).
  • We need some additional validation to make sure we are never losing nodes etc. This is unlikely, but definitely possible given the current code.
  • Currently the position and sqid variables are hardcoded into the submitter. We should be passing either those values or the view in $form_state['storage'] so it uses the configurations that are set.
  • Absolutely positively needs tests.

So that's where we're at. I'm probably not going to have a lot of bandwidth to mess with this for at least a few days, so if others want to run with it for a bit then I say go for it.

Just in case anyone has problems getting a view setup for this, here's an export of my local view for comparison:

$view = new view;
$view->name = 'favorites_reorder';
$view->description = 'Allows a user to reorder their favorites';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'nodequeue_rel' => array(
    'label' => 'queue',
    'required' => 1,
    'limit' => 1,
    'qids' => array(
      '1' => '1',
    ),
    'id' => 'nodequeue_rel',
    'table' => 'node',
    'field' => 'nodequeue_rel',
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'field_photo_image_fid' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'label_type' => 'none',
    'format' => 'thumbnail_3x2_180x120_default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_photo_image_fid',
    'table' => 'node_data_field_photo_image',
    'field' => 'field_photo_image_fid',
    'relationship' => 'none',
  ),
  'position' => array(
    'label' => 'Position',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'set_precision' => FALSE,
    'precision' => 0,
    'decimal' => '.',
    'separator' => ',',
    'prefix' => '',
    'suffix' => '',
    'exclude' => 0,
    'id' => 'position',
    'table' => 'nodequeue_nodes',
    'field' => 'position',
    'relationship' => 'nodequeue_rel',
  ),
  'sqid' => array(
    'label' => 'Subqueue ID',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'set_precision' => FALSE,
    'precision' => 0,
    'decimal' => '.',
    'separator' => ',',
    'prefix' => '',
    'suffix' => '',
    'exclude' => 1,
    'id' => 'sqid',
    'table' => 'nodequeue_nodes',
    'field' => 'sqid',
    'relationship' => 'nodequeue_rel',
  ),
));
$handler->override_option('sorts', array(
  'position' => array(
    'order' => 'ASC',
    'id' => 'position',
    'table' => 'nodequeue_nodes',
    'field' => 'position',
    'relationship' => 'nodequeue_rel',
  ),
));
$handler->override_option('arguments', array(
  'reference' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'id' => 'reference',
    'table' => 'nodequeue_subqueue',
    'field' => 'reference',
    'relationship' => 'nodequeue_rel',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'blog' => 0,
      'poll' => 0,
      'forum' => 0,
      'book' => 0,
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '2' => 0,
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('empty', 'This user does not have a queue that contains any posts.');
$handler->override_option('empty_format', '1');
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'draggable_queue_list');
$handler->override_option('style_options', array(
  'type' => 'ul',
  'draggable_nodequeues_order' => array(
    'field' => 'position',
  ),
  'draggable_nodequeues_subqueue' => array(
    'field' => 'sqid',
  ),
  'draggable_nodequeues_auto_submit' => array(
    'field' => '0',
  ),
));
$handler->override_option('row_plugin', 'node');
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'reorder-favorites');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));

ezra-g’s picture

Status: Active » Needs review

I still need to code review this, but responding to your list of things that need to be improved:

> * The javascript needs some work. In particular, it needs to be refactored to allow for multiple of these > on the same page. I've already started namespacing the views in the Drupal.settings array.
This would be great but is something that's not supported by the current drag&drop interface. I don't think it should prevent this from being committed.
> * The javascript needs to be updated to correctly use the start_at variable that's being set in
> Drupal.settings. Currently it doesn't do anything with offsets (think paged views).
Same as above.
> * We need some additional validation to make sure we are never losing nodes etc. This is unlikely, but
> definitely possible given the current code.
Yikes. I'll take a closer look to see why but yeah, let's not lose nodes ;)

> * Currently the position and sqid variables are hardcoded into the submitter. We should be passing
> either those values or the view in $form_state['storage'] so it uses the configurations that are set.
Definitely.

> * Absolutely positively needs tests.
Again, this shouldn't prevent it from being committed :).

ezra-g’s picture

Also, awesome -- Thanks!!11!!!

beeradb’s picture

I should also note, that even though this issue is tagged as 7.x, the current code is a 6.x module.

beeradb’s picture

Status: Needs work » Needs review

A couple other thoughts I had on stuff that will need work here.

Validation is the big one, at this point I'm basically trusting people build their view correctly. We should be performing the exact same validation that nodequeue_save_subqueue_order on the reordered subqueue and presenting the appropriate messages to the user on failure, or perhaps patch nodequeue so those checks happen in an API function, which we (and nodequeue_save_subqueue_order) call. Additionally, we should add in checks to make sure only one sqid is present in the result set, and flag a validation error if that's not the case. As is, the submitted grabs the first sqid it finds, and just assumes that's the subqueue it's working with. Without this check in place nodes could be arbitrarily added to subqueues.

Neither of these are difficult tasks, but I'm making a note here so they don't fall off the radar.

izmeez’s picture

subscribing, this will be very cool.

hatsch’s picture

this sounds amazing! this might open great further possibilities.

Imagine a two column page. one column holds the nodequeue, the other column holds another view with exposed filters or built with search_api. one can easily drag nodes from the "search view" to the "nodequeue view".

this would be a major enhancement for building nodequeues.

chrisschaub’s picture

Wondering if you ever did more with this? I can get it to reorder, but only the first item sticks. So, only ordering sticks for the first item in the list. The lower items position doesn't save.

chrisschaub’s picture

Ok, this issue is this line:

$('.draggable-nodequeue-sort-field', this).val(index + 1);

which will work fine if you drag "down", but if you drag "up", then we need something like:

$('.draggable-nodequeue-sort-field', this).val(index - 1);

beeradb’s picture

FileSize
7.54 KB

That line is actually correct. It loops over all of the LI's in the list and sets the subqueue position to index + 1, meaning the first element will be position 1, second element 2, etc.

I've done a bit more work on this. Kinda got lost in the fray of rushing towards Alpha on the project I built it for.

Either way, I think I've listed all of the current known issues (which are fairly minor) so there's nothing holding this back from getting a more extensive review/feedback to see if there is anything in addition to the issues I've outlined.

Here's the latest version I've been working with - it has a handful of improvements including a more stable submit handler (should not have any chance of losing nodes anymore) and better support for nested li's (I was running into an issue when adding 'remove' links to draggable nodequeues).

chrisschaub’s picture

Cool, but the ordering isn't working for me when I drop it upwards. What version of jquery ui are you using 1.6? I should clarify, when I drag the link upwards to the first position, it doesn't stick. It works when I drag down, but not up. After I click save, the order is gone. I was looking at the refresh call in the jquery for sortable? It's odd that it works down, but now up in the order. I am on a mac tho, but Firefox.

beeradb’s picture

@schaub123: Are you still seeing that behavior with the latest version I uploaded?

I was having some issues with things sporadically not saving previously, but that should be fixed in the latest version as I'm not seeing that bug anymore. I actually forget the details of what the cause was, so I'll have to look up commit history to see what change was made.

Let me know, and thanks for testing!

chrisschaub’s picture

Yes, I downloaded and tested, still same issue, If you drag an item to top of list, it doesn't stick. Only when you drag downward below current position. I'm using latest drupal 6 jquery ui 1.6. Thanks, cool module. I'll start debugging a bit.

beeradb’s picture

if you can paste a views export and/or a feature to show what your setup is, I don't mind taking a look. I'm not seeing that behavior at all on this end.

chrisschaub’s picture

I'm just using your view. Can you tell me what version of jquery and jquery_ui you are using? It might be jquery_ui and the sortable method. I've tried on firefox, safari and chrome on mac osx.

beeradb’s picture

jquery v1.3.2 via the jquery_update module, jquery_ui version jQuery UI 1.7.3 via the jquery_ui module.

chrisschaub’s picture

ahh, it's probably the jquery 1.7.3. the sortable interface changed radically in 1.7 from 1.6. i'll check that

chrisschaub’s picture

Ok, that did it. Make sure when you release this cool module, you mention that jquery update 2.x and jquery_ui with 1.7 are required. Would not work without jquery 1.3.x. Thanks!

beeradb’s picture

Awesome -- glad that got ironed out. I had actually forgotten we were even using jquery_update or I would have mentioned it :)

Other than that, are you seeing any strange behavior? let me know after you have a few minutes to play with it.

Thanks!

beeradb’s picture

FileSize
9.27 KB

New version. Adds support for specifying a CSS class for a drag handle, also properly respects the "hide from display" flag in views.

delykj’s picture

subscr

karljohann’s picture

Subscribing. Are there plans to make this an official module or adding it as a sub-module to Nodequeue?

karljohann’s picture

I'm not getting this to work. I've tried everything I can think of, Views2 and 3, Jquery 1.2, 1.3.2 and 1.5, jquery ui 1.6 and 1.7, three seperate themes (including Garland) and almost every combination of the above.

What happens is that I can re-order the nodes but they won't stick once I've hit save. I've followed the instructions above and tried various other things but they won't stick. Only thing different is I'm using node titles to re-order and not images.

Any help would be greatly appreciated!

karljohann’s picture

One thing I noticed is that the module calls for ui.widget and ui.mouse. Neither one of these files are in jquery ui 1.7 or 1.6 so the files are not found.

hatsch’s picture

anything new on this? this feature would definitly be a major enhancement!

is there a chance that someone would pick up a bounty?
i'd chip in the first 100 euro

ezra-g’s picture

One thing I noticed is that the module calls for ui.widget and ui.mouse. Neither one of these files are in jquery ui 1.7 or 1.6 so the files are not found.

It sounds like this patch needs work.

This would be a huge improvement to providing a better and more flexible Nodequeue UI.

To help move this forward, it would be great if someone could review this patch and address the feedback from #28 and above.

earthangelconsulting’s picture

any hope for a 7.x version of this?

jenlampton’s picture

Issue summary: View changes
Status: Needs review » Active

Changing status from NR to active since it doesn't look like there's a patch to review yet, or even a 7.x version of the module to adapt. Great work though by @beeradb, it shouldn't be too hard to start from this D6 module.