Change class name view-grid as default if no ?display= in the URL
Fixed the issue of unable to change sort dropdown of Search Result Pager
This commit is contained in:
parent
9836edfb58
commit
8ec130bf8e
2 changed files with 17 additions and 1 deletions
|
|
@ -126,7 +126,7 @@ function islandora_advanced_search_preprocess_views_view(&$variables) {
|
|||
// has been created for.
|
||||
if (in_array([$view->id(), $view->current_display], $views)) {
|
||||
// Toggle between 'list' and 'grid' display depending on url parameter.
|
||||
$format = \Drupal::request()->query->get('display') ?? 'list';
|
||||
$format = \Drupal::request()->query->get('display') ?? 'grid';
|
||||
$variables['attributes']['class'][] = "view-{$format}";
|
||||
$view->element['#attached']['library'][] = 'islandora_advanced_search/advanced.search.pager';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,22 @@
|
|||
window.history.pushState(null, document.title, $(this).attr("href"));
|
||||
});
|
||||
|
||||
/* digitalutsc added */
|
||||
$('.pager__sort select[name="order"]')
|
||||
.once()
|
||||
.change(function () {
|
||||
var href = window.location.href;
|
||||
var params = Drupal.Views.parseQueryString(href);
|
||||
|
||||
var selection = $(this).val();
|
||||
var option = selection.split('_');
|
||||
params.sort_by = option[0];
|
||||
params.sort_order = option[1].toUpperCase();
|
||||
|
||||
href = href.split("?")[0] + "?" + $.param(params);
|
||||
window.history.pushState(null, document.title, href);
|
||||
});
|
||||
|
||||
// Trigger on sort change.
|
||||
$('[data-drupal-pager-id] select[name="order"]')
|
||||
.once()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue