When trying to reorder galleries (by drag and drop), the UI updates fine, but reloading the galleries page still shows the previous ordering.

Checking the Drupal log indicates the following error (for location: (…)media-gallery/sort/collection/8/B-Yn0CeVdHapMqlLHm2J1zSRXbZV0IiQ4hxlOg4d1eY):

PDOException : SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'weight' at row 12: INSERT INTO {media_gallery_weight} (tid, nid, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2), (:db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5), (:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8), (:db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11), (:db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14), (:db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17), (:db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20), (:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23), (:db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26), (:db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29), (:db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32), (:db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35); Array ( [:db_insert_placeholder_0] => 8 [:db_insert_placeholder_1] => 47 [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => 8 [:db_insert_placeholder_4] => 48 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 8 [:db_insert_placeholder_7] => 49 [:db_insert_placeholder_8] => 2 [:db_insert_placeholder_9] => 8 [:db_insert_placeholder_10] => 50 [:db_insert_placeholder_11] => 3 [:db_insert_placeholder_12] => 8 [:db_insert_placeholder_13] => 51 [:db_insert_placeholder_14] => 4 [:db_insert_placeholder_15] => 8 [:db_insert_placeholder_16] => 52 [:db_insert_placeholder_17] => 5 [:db_insert_placeholder_18] => 8 [:db_insert_placeholder_19] => 69 [:db_insert_placeholder_20] => 6 [:db_insert_placeholder_21] => 8 [:db_insert_placeholder_22] => 81 [:db_insert_placeholder_23] => 7 [:db_insert_placeholder_24] => 8 [:db_insert_placeholder_25] => 82 [:db_insert_placeholder_26] => 8 [:db_insert_placeholder_27] => 8 [:db_insert_placeholder_28] => 83 [:db_insert_placeholder_29] => 9 [:db_insert_placeholder_30] => 8 [:db_insert_placeholder_31] => 104 [:db_insert_placeholder_32] => 10 [:db_insert_placeholder_33] => 8 [:db_insert_placeholder_34] => 0 [:db_insert_placeholder_35] => ) dans media_gallery_reorder_collection() (ligne 213 dans /home/www/993440415919ae086f7bb1f8b34974d3/web/sites/all/modules/media_gallery/media_gallery.pages.inc).

In the log follows a series of notices like this one:

Notice : Undefined offset: 0 dans _media_gallery_reorder() (ligne 252 dans /home/www/993440415919ae086f7bb1f8b34974d3/web/sites/all/modules/media_gallery/media_gallery.pages.inc).

Files: 

Comments

Status:Active» Postponed (maintainer needs more info)

Status:Postponed (maintainer needs more info)» Needs review

Solution:

In your theme, the node.tpl or node-media-gallery.tpl must have this wrapper (the id with called node-[NID]):

<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

Status:Needs review» Postponed (maintainer needs more info)

We still need to know which theme.

I have this trouble with Omega.

#1431344: Drag and drop does not work - solution for all themes. Does not fix my problem

Adaptive Theme:
- this issue is fixed with adaptive theme 7.x-3.x (in previous versions, they replace the html-id from 'node-$nid' to 'article-$nid')

Omega:
- this issue is still there.

The problem:
media_gallery sets for each media-item in a gallery a html-id. Therefore the drag&drop in a gallery is stored, as expected.
media_gallery does not set a html-id for the galleries collection items (the gallery nodes). There the default html-id "node-$nid" is assumed and used. Themes like omega build the attribute "id" in this way:

/**
* Implements hook_preprocess_node().
*/
function omega_alpha_preprocess_node(&$vars) {
  // Prepare the arrays to handle the classes and ids for the node container.
  $vars['attributes_array']['id'] = drupal_html_id('node-' . $vars['type'] . '-' . $vars['nid']);

As can be seen in this code, Omega inserts the type into the id-attribute. Therefore the media_gallery function media_gallery_ajax_sort uses the wrong prefix 'node-' instead of 'node-media-gallery-'.

Are there other themes, which set the id-attribute in such a way?

Sorry, but I am not able to say whether there are there other themes which set the id-attribute in such a way. Only to say that as of today, Omega has 40,893 installs and is also bundled with important distributions such as Commerce Kickstart.

Can a fix be implemented before Beta 9 which would satisfy this large body of effected sites?

Status:Postponed (maintainer needs more info)» Needs review
StatusFileSize
new867 bytes

Applied a patch to find the prefix in a dynamic way.

Works for me. Fantastic

Well done Moloc. Is this likely to be the permanent solution?

Yes, it is a permanent solution. I will commit it this week, before creating the 2.x branch. So it will be in both versions.

If you find a better solution, just let me/us know.

Status:Needs review» Fixed

Commited patch.

Status:Fixed» Closed (fixed)

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