diff --git a/includes/views/node_gallery.views_default.inc b/includes/views/node_gallery.views_default.inc index e49671e..72feede 100644 --- a/includes/views/node_gallery.views_default.inc +++ b/includes/views/node_gallery.views_default.inc @@ -76,6 +76,11 @@ function node_gallery_views_default_views() { $handler->display->display_options['fields']['node_gallery_media']['alter']['make_link'] = TRUE; $handler->display->display_options['fields']['node_gallery_media']['alter']['path'] = 'node/[nid]'; $handler->display->display_options['fields']['node_gallery_media']['element_label_colon'] = FALSE; + /* Sort criterion: Node Gallery Relationship: Item Weight (Sort Order) */ + $handler->display->display_options['sorts']['weight']['id'] = 'weight'; + $handler->display->display_options['sorts']['weight']['table'] = 'node_gallery_relationship'; + $handler->display->display_options['sorts']['weight']['field'] = 'weight'; + $handler->display->display_options['sorts']['weight']['relationship'] = 'node_gallery_relationship_ngid'; /* Sort criterion: Content: Nid */ $handler->display->display_options['sorts']['nid']['id'] = 'nid'; $handler->display->display_options['sorts']['nid']['table'] = 'node'; @@ -172,6 +177,11 @@ function node_gallery_views_default_views() { $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['title']['alter']['trim'] = TRUE; $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + $handler->display->display_options['defaults']['sorts'] = FALSE; + /* Sort criterion: Content: Nid */ + $handler->display->display_options['sorts']['nid']['id'] = 'nid'; + $handler->display->display_options['sorts']['nid']['table'] = 'node'; + $handler->display->display_options['sorts']['nid']['field'] = 'nid'; /* Display: Image Sort */ $handler = $view->new_display('embed', 'Image Sort', 'embed_5'); diff --git a/node_gallery_api.inc b/node_gallery_api.inc index e0f867a..c7422f0 100644 --- a/node_gallery_api.inc +++ b/node_gallery_api.inc @@ -733,19 +733,15 @@ function node_gallery_api_get_item_nids($ngid, $sorted = TRUE, $filtered = TRUE, if (!$fallback) { $gallery = node_load($ngid); $relationship_type = node_gallery_api_get_relationship_type($gallery->type); - list($view_name, $view_display) = explode(':', $relationship_type->settings['item_view']['view_navigator_item_display']); + $view_name = ''; + $view_display = ''; + if (!empty($relationship_type->settings['item_view']['view_navigator_item_display'])) { + list($view_name, $view_display) = explode(':', $relationship_type->settings['item_view']['view_navigator_item_display']); + } if (isset($view_name)) { $view = views_get_view($view_name); - if (!isset($view->display[$view_display])) { - $message = t('Unable to find the sort view specified in the !relationship, maybe you need to !revert your view?', - array( - '!revert' => l(t('revert'), 'admin/structure/views/delete/' . $view_name), - '!relationship' => l(t('relationship settings'), 'admin/config/content/node-gallery/relationship-type/settings/' . $relationship_type->id), - ) - ); - } - else { + if (isset($view->display[$view_display])) { $view->set_display($view_display); $view->set_arguments(array($gallery->nid)); if (!$sorted) { @@ -770,11 +766,8 @@ function node_gallery_api_get_item_nids($ngid, $sorted = TRUE, $filtered = TRUE, } } } - else { - $message = t('Unable to find a navigator image sort view. Please revisit your !rellink.', array('!rellink' => l(t('Node Gallery relationship settings'), 'admin/config/content/node_gallery/relationship/settings/' . $relationship_type->id))); - } } - if (isset($message) || $fallback) { + if (isset($message) || $fallback || !isset($query)) { $query_field_name = 'nid'; $query = db_select('node_gallery_relationship', 'ng')->fields('ng', array('nid')); $query->join('node', 'n', 'ng.nid = n.nid'); diff --git a/node_gallery_api.install b/node_gallery_api.install index 08fffe1..9915f40 100644 --- a/node_gallery_api.install +++ b/node_gallery_api.install @@ -186,6 +186,15 @@ function node_gallery_api_update_7000() { } /** + * NOTE: After this update, you may need to revert the view called "Node Gallery: Gallery Item Views" to repair issues related to sorting order. This can be done under Structure, Views. Expand the edit button and choose "revert". If you have intentionally customized this view, make sure the sort order includes Node Gallery weight. + */ +function node_gallery_api_update_7001() { + // This is just a message to the user. + $t = get_t(); + return $t('NOTE: After this update, you may need to revert the view called "Node Gallery: Gallery Item Views" to repair issues related to sorting order. This can be done under Structure, Views. Expand the edit button and choose "revert". If you have intentionally customized this view, make sure the sort order includes Node Gallery weight.'); +} + +/** * Sets up the admin view mode for Management pages. */ function node_gallery_api_setup_display_modes() { diff --git a/node_gallery_api.pages.inc b/node_gallery_api.pages.inc index bd06070..a1febd8 100644 --- a/node_gallery_api.pages.inc +++ b/node_gallery_api.pages.inc @@ -31,7 +31,9 @@ function node_gallery_api_sort_items_form($form, $form_state, $gallery, $no_jque $images = node_gallery_api_get_items($gallery, TRUE, FALSE); $image_count = count($images); - $jquery_ui_integration = variable_get('node_gallery_jquery_ui_integration', TRUE) && $no_jquery != 'no_jquery'; + // @todo: Fix jquery UI integration. + // $jquery_ui_integration = variable_get('node_gallery_jquery_ui_integration', TRUE) && $no_jquery != 'no_jquery'; + $jquery_ui_integration = FALSE; $max_image_count = variable_get('node_gallery_sort_images_max', 750); if ($image_count > $max_image_count) { drupal_set_message(t('There are too many images in this gallery to display. You can increase the limit by !settings_url. The current limit is !max.', array('!settings' => 'admin/config/node_gallery/settings', '!max' => $max_image_count)), 'warning');