-
Notifications
You must be signed in to change notification settings - Fork 2
2. Module embedding
Here is the step by step guidance to enable this module:
-
Add the following line to
composer.json:- dev-package:
"ubtue/vufind-collapse-expand": "@dev" - for VuFind 10:
"ubtue/vufind-collapse-expand": "dev-release-10.2" - for VuFind 11:
"ubtue/vufind-collapse-expand": "dev-release-11.0"
Note that a more concise versioning schema will be introduced as soon as the first release is created (for matching VuFind version).
- dev-package:
-
Update composer package (via terminal):
composer update -
Add the module to
application.config.phpin the config folder.$module = [ ... 'VuFindCollapseExpand', ... ]For advanced users, it's also possible to copy the into
modulesand enable it inhttpd-vufind.conf. But then you need to care about updates yourself. -
Add the trait In your record driver
RecordDriver/SolrDefault(ex. RecordDriver/SolrDefault.php), there are several changes necessary:class SolrDefault extends \VuFind\RecordDriver\SolrMarc implements \VuFindCollapseExpand\Config\CollapseExpandConfigAwareInterface { ... use \VuFindCollapseExpand\RecordDriver\Feature\CollapseExpandTrait; use \VuFindCollapseExpand\Config\CollapseExpandConfigAwareTrait; ... }
Add the config to config.ini
; When the collapse.field is set, the feature itself is enabled.
; With activated_by_default you can preset the users activation choice
; The collapse.field is recommended to set the same value with expand.field
; If you want to override defaults / use specific features, please have a look at the Solr Documentation:
; https://solr.apache.org/guide/solr/latest/query-guide/collapse-and-expand-results.html
; mandatory collapse fields are collapse.field, expand.field and expand.rows.
[CollapseExpand]
; activated_by_default sets the initial state of the grouping (default = true)
; users can override this by clicking the checkbox
activated_by_default = true
collapse.field = title_sort
;collapse.min =
;collapse.max =
;collapse.sort =
;collapse.nullPolicy = ignore
;collapse.hint =
;collapse.size = 100000
;collapse.collectElevatedDocsWhenCollapsing = true
expand.field = title_sort
expand.rows = 500
;expand.sort = score desc
;expand.q =
;expand.fq =
;expand.nullGroup = falseAdd the mixin to your custom theme by referencing it in your theme.config.php:
'mixins' => ['vufind-collapse-expand']
Copy the corresponding folder from this module into the VuFind theme folder or create a symlink to it:
vendor/ubtue/vufind-collapse-expand/res/theme => themes/vufind-collapse-expand
The following sections contain information about how to include certain snippets. You might as well also extend/override them in your own theme if necessary.
-
Checkbox (search control) for en-/disabling the grouping
Add a reference in your search/results.phtml to the result-list-snippet.phtml Copy the code in the file
res/theme/templates/search/controls/collapse_expand.htmlwhere you want the checkbox for enabling/ disabling CollapseExpand dynamically, for example in[your_theme]/templates/search/results.html -
enrich single result with grouped items
Add a reference in your result-list.phtml to the result-list-snippet.phtml
<?=$this->render('RecordDriver/DefaultRecord/result-list-snippet.phtml')?>A good point for adding this include would be at the bottom of
<div class="media-body">, right before the</div>.
CollapseExpand comes with a record tab called Other Document to show the expand documents when user access the detail information of the record. Using the feature is simple, just follow the instruction below to activate.
RecordTabs.ini (config/vufind/RecordTabs.ini)
[VuFind\RecordDriver\SolrMarc]
...
tabs[CollapseExpand] = CollapseExpand
...Adding the translation into [language].ini for example the english translation:
...
collapse results = "Collapse similar items"
expand results = "Expand similar items"Note: This might not be necessary if the mixin is included properly, unless you want to override the default display texts.