Skip to content
Snippets Groups Projects
Commit 7b83ab1b authored by Demian Katz's avatar Demian Katz
Browse files

Extra columns in alphabrowse (resolves VUFIND-863).

Thanks to Tod Olson.
parent c7ac2a0f
No related merge requests found
......@@ -791,6 +791,14 @@ title = "By Title"
lcc = "By Call Number"
;dewey = "By Call Number"
; This section controls the return of extra columns for the different browses.
; The key is the browse index, the value is a colon-separated string of extra
; Solr fields to return for display to the user.
[AlphaBrowse_Extras]
title = "author:format:publishDate"
lcc = title
dewey = title
; This section allows you to configure the values used for Cryptography; the
; HMACkey can be set to any value you like and should never be shared. It is used
; to prevent users from tampering with certain URLs (for example, "place hold" form
......
......@@ -28,6 +28,7 @@
*/
namespace VuFind\Controller;
use VuFindSearch\ParamBag;
/**
* AlphabrowseController Class
*
......@@ -68,6 +69,14 @@ class AlphabrowseController extends AbstractBase
);
}
// Load any extras from config file
$extras = array();
if (isset($config->AlphaBrowse_Extras)) {
foreach ($config->AlphaBrowse_Extras as $key => $value) {
$extras[$key] = $value;
}
}
// Connect to Solr:
$db = $this->getServiceLocator()->get('VuFind\Search\BackendManager')
->get('Solr');
......@@ -79,6 +88,12 @@ class AlphabrowseController extends AbstractBase
$limit = isset($config->AlphaBrowse->page_size)
? $config->AlphaBrowse->page_size : 20;
// Set up any extra parameters to pass
$extraParams = new ParamBag();
if (isset($extras[$source])) {
$extraParams->add('extras', $extras[$source]);
}
// Create view model:
$view = $this->createViewModel();
......@@ -86,13 +101,13 @@ class AlphabrowseController extends AbstractBase
// If required parameters are present, load results:
if ($source && $from !== false) {
// Load Solr data or die trying:
$result = $db->alphabeticBrowse($source, $from, $page, $limit);
$result = $db->alphabeticBrowse($source, $from, $page, $limit, $extraParams);
// No results? Try the previous page just in case we've gone past
// the end of the list....
if ($result['Browse']['totalCount'] == 0) {
$page--;
$result = $db->alphabeticBrowse($source, $from, $page, $limit);
$result = $db->alphabeticBrowse($source, $from, $page, $limit, $extraParams);
}
// Only display next/previous page links when applicable:
......@@ -108,6 +123,11 @@ class AlphabrowseController extends AbstractBase
$view->alphaBrowseTypes = $types;
$view->from = $from;
$view->source = $source;
// Pass information about extra columns on to theme
if (isset($extras[$source])) {
$view->extras = explode(':', $extras[$source]);
}
return $view;
}
}
\ No newline at end of file
......@@ -201,6 +201,13 @@ ul.cartContent {
background-color: #fff;
}
.alphaBrowseExtra {
display: block;
float: left;
padding-left: .75em;
line-height: 1.31em;
}
.alphaBrowseForm {
zoom: 1;
}
......@@ -211,6 +218,41 @@ ul.cartContent {
line-height: 1.31em;
}
.alphaBrowseSource_dewey .alphaBrowseHeading {
width: 200px;
padding-right: .5em;
}
.alphaBrowseSource_dewey .alphaBrowseColumn_title {
width: 450px;
}
.alphaBrowseSource_lcc .alphaBrowseHeading {
width: 200px;
padding-right: .5em;
}
.alphaBrowseSource_lcc .alphaBrowseColumn_title {
width: 450px;
}
.alphaBrowseSource_title .alphaBrowseHeading {
width: 300px;
padding-right: .5em;
}
.alphaBrowseSource_title .alphaBrowseColumn_author {
width: 200px;
}
.alphaBrowseSource_title .alphaBrowseColumn_format {
width: 100px;
}
.alphaBrowseSource_title .alphaBrowseColumn_publishDate {
width: 45px;
}
.alphaBrowseCount {
float: right;
}
......
......@@ -40,8 +40,8 @@
<div class="alphaBrowseHeader"><?=$this->transEsc("alphabrowse_matches") ?></div>
<? foreach ($this->result['Browse']['items'] as $i => $item): ?>
<div class="alphaBrowseEntry<? if ($i%2==1): echo ' alt'; endif; ?>">
<div class="alphaBrowseHeading">
<div class="alphaBrowseEntry<? if ($i%2==1): echo ' alt'; endif; ?> alphaBrowseSource_<?=$this->escapeHtml($this->source)?>">
<div class="alphaBrowseHeading alphaBrowseHeading_<?=$this->escapeHtml($this->source)?>">
<? if ($item['count'] > 0): ?>
<?/* linking using bib ids is generally more reliable than
doing searches for headings, but headings give shorter
......@@ -56,6 +56,20 @@
<?=$this->escapeHtml($item['heading'])?>
<? endif; ?>
</div>
<?
foreach ($this->extras as $ei => $extraName):
$extraData = $item['extras'][$extraName];
?>
<div class="alphaBrowseExtra alphaBrowseColumn_<? echo $extraName?>">
<?
$extraDisplayArray = array();
foreach ($extraData as $j => $e) {
$extraDisplayArray = array_unique(array_merge($extraDisplayArray, $e));
}
echo (empty($extraDisplayArray)) ? '&nbsp;' : implode('<br />', $extraDisplayArray);
?>
</div>
<? endforeach; ?>
<div class="alphaBrowseCount"><? if ($item['count'] > 0): echo $item['count']; endif; ?></div>
<div class="clear"></div>
......
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