diff --git a/config/vufind/searches.ini b/config/vufind/searches.ini index 0fa54d01400f..03accc7ae3ae 100644 --- a/config/vufind/searches.ini +++ b/config/vufind/searches.ini @@ -591,6 +591,9 @@ ranges = 1,5,30 result_pages = 10 ; The default sort to use (if different from the normally configured default). ;default_sort = year +; To include pre-filtering facet options, set to the name of a valid facet context +; (e.g. HomePage or Advanced). +;facet_context = Advanced ; This setting can be used to automatically apply filter queries to the New Item ; results. For example, you might want to filter out certain content types. You ; can add multiple filters by repeating the "filter[] =" line, or you can skip diff --git a/module/VuFind/src/VuFind/Controller/AbstractSolrSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSolrSearch.php index 292855d152ad..5ec29c607d7e 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSolrSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSolrSearch.php @@ -30,6 +30,8 @@ namespace VuFind\Controller; +use Laminas\View\Model\ViewModel; + use function in_array; /** @@ -47,20 +49,19 @@ class AbstractSolrSearch extends AbstractSearch use Feature\RecordVersionsSearchTrait; /** - * Handle an advanced search + * Set up facet details in the view (for use in advanced search and similar). * - * @return mixed + * @param ViewModel $view View model to update + * @param string $list Name of facet list to retrieve + * + * @return void */ - public function advancedAction() + protected function addFacetDetailsToView(ViewModel $view, $list = 'Advanced'): void { - // Standard setup from base class: - $view = parent::advancedAction(); - - // Set up facet information: $facets = $this->serviceLocator ->get(\VuFind\Search\FacetCache\PluginManager::class) ->get($this->searchClassId) - ->getList('Advanced'); + ->getList($list); $view->hierarchicalFacets = $this->getHierarchicalFacets($view->options->getFacetsIni()); $view->hierarchicalFacetsSortOptions @@ -69,10 +70,24 @@ public function advancedAction() ); $view->facetList = $this->processAdvancedFacets( $facets, - $view->saved, + $view->saved ?? false, $view->hierarchicalFacets, $view->hierarchicalFacetsSortOptions ); + } + + /** + * Handle an advanced search + * + * @return mixed + */ + public function advancedAction() + { + // Standard setup from base class: + $view = parent::advancedAction(); + + // Set up facet information: + $this->addFacetDetailsToView($view); $specialFacets = $this->parseSpecialFacetsSetting( $view->options->getSpecialAdvancedFacets() ); diff --git a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php index cf23cb542172..054df216ea5c 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php @@ -114,6 +114,16 @@ public function getDefaultSort(): ?string return $this->config->default_sort ?? null; } + /** + * Get facet section setting (null for none). + * + * @return ?string + */ + public function getFacetContext(): ?string + { + return $this->config->facet_context ?? null; + } + /** * Get fund list * diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 6a28bb096b62..9b769bd7618c 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -235,13 +235,20 @@ public function newitemAction() return $this->forwardTo('Search', 'NewItemResults'); } - return $this->createViewModel( + $view = $this->createViewModel( [ 'defaultSort' => $this->newItems()->getDefaultSort(), 'fundList' => $this->newItems()->getFundList(), 'ranges' => $this->newItems()->getRanges(), ] ); + if ($facetContext = $this->newItems()->getFacetContext()) { + $view->options = $this->serviceLocator + ->get(\VuFind\Search\Options\PluginManager::class) + ->get($this->searchClassId); + $this->addFacetDetailsToView($view, $facetContext); + } + return $view; } /** diff --git a/themes/bootstrap3/templates/search/advanced/solr-facets.phtml b/themes/bootstrap3/templates/search/advanced/solr-facets.phtml new file mode 100644 index 000000000000..876bee899266 --- /dev/null +++ b/themes/bootstrap3/templates/search/advanced/solr-facets.phtml @@ -0,0 +1,60 @@ +facetList) || !empty($this->checkboxFacets)): ?> +
+ diff --git a/themes/bootstrap3/templates/search/advanced/solr.phtml b/themes/bootstrap3/templates/search/advanced/solr.phtml index 27abbff9eebd..f65e4978e3db 100644 --- a/themes/bootstrap3/templates/search/advanced/solr.phtml +++ b/themes/bootstrap3/templates/search/advanced/solr.phtml @@ -1,63 +1,4 @@ -facetList) || !empty($this->checkboxFacets)): ?> - - +=$this->render('search/advanced/solr-facets.phtml')?> illustratedLimit)): ?>