Skip to content
Snippets Groups Projects
Commit c89a8746 authored by Brandon Uhlman's avatar Brandon Uhlman Committed by Demian Katz
Browse files

Fix next/prev scrolling for author facet searches

When running a keyword search, then choosing an author hyperlink from the
results to run an author facet search, the next/previous links in the individual
results would be based on the initial keyword search, not the facet search.

This was for two reasons:
- the ResultScroller was not active in the AuthorController, which handles
author facet searches
- the ResultScroller retrieves the current search from the session to create
the scrolling links, and author facet searches were configured to not
be saved in the session

Correct these two issues in AuthorController, but only if next_prev_navigation
is enabled. Because AuthorController also handles SolrAuthorFacet searches
(searches that produce a list of authors, not a list of titles by a specific author)
and those results cannot be iterated through by a ResultScroller, we also have
to make an additional fix in the ResultScroller plugin to handle the case
where SolrAuthorFacet result is passed to create the ResultScroller, and
prevent it from being instantiated.
parent 3ba3a0e8
No related merge requests found
......@@ -46,7 +46,14 @@ class AuthorController extends AbstractSearch
public function resultsAction()
{
$this->searchClassId = 'SolrAuthor';
$this->saveToHistory = false;
// Save author searches if next_prev_navigation is enabled - otherwise
// there are wacky results when trying to page through results (the
// next/prev links only appear for records which were included in the
// results for the previous keyword search, and the next/prev links will
// iterate you through that search).
$this->saveToHistory = $this->resultScrollerActive();
return parent::resultsAction();
}
......@@ -78,5 +85,17 @@ class AuthorController extends AbstractSearch
}
return $this->createViewModel();
}
/**
* Is the result scroller active?
*
* @return bool
*/
protected function resultScrollerActive()
{
$config = $this->getServiceLocator()->get('VuFind\Config')->get('config');
return (isset($config->Record->next_prev_navigation)
&& $config->Record->next_prev_navigation);
}
}
......@@ -98,7 +98,7 @@ class ResultScroller extends AbstractPlugin
unset($this->data->prevIds);
unset($this->data->nextIds);
return true;
return (bool)$this->data->currIds;
}
/**
......@@ -393,6 +393,9 @@ class ResultScroller extends AbstractPlugin
$retVal = [];
foreach ($searchObject->getResults() as $record) {
if (!($record instanceof \VuFind\RecordDriver\AbstractBase)) {
return false;
}
$retVal[] = $record->getResourceSource() . '|' . $record->getUniqueId();
}
return $retVal;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment