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
Branches
Tags
No related merge requests found
...@@ -791,6 +791,14 @@ title = "By Title" ...@@ -791,6 +791,14 @@ title = "By Title"
lcc = "By Call Number" lcc = "By Call Number"
;dewey = "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 ; 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 ; 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 ; to prevent users from tampering with certain URLs (for example, "place hold" form
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
*/ */
namespace VuFind\Controller; namespace VuFind\Controller;
use VuFindSearch\ParamBag;
/** /**
* AlphabrowseController Class * AlphabrowseController Class
* *
...@@ -68,6 +69,14 @@ class AlphabrowseController extends AbstractBase ...@@ -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: // Connect to Solr:
$db = $this->getServiceLocator()->get('VuFind\Search\BackendManager') $db = $this->getServiceLocator()->get('VuFind\Search\BackendManager')
->get('Solr'); ->get('Solr');
...@@ -79,6 +88,12 @@ class AlphabrowseController extends AbstractBase ...@@ -79,6 +88,12 @@ class AlphabrowseController extends AbstractBase
$limit = isset($config->AlphaBrowse->page_size) $limit = isset($config->AlphaBrowse->page_size)
? $config->AlphaBrowse->page_size : 20; ? $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: // Create view model:
$view = $this->createViewModel(); $view = $this->createViewModel();
...@@ -86,13 +101,13 @@ class AlphabrowseController extends AbstractBase ...@@ -86,13 +101,13 @@ class AlphabrowseController extends AbstractBase
// If required parameters are present, load results: // If required parameters are present, load results:
if ($source && $from !== false) { if ($source && $from !== false) {
// Load Solr data or die trying: // 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 // No results? Try the previous page just in case we've gone past
// the end of the list.... // the end of the list....
if ($result['Browse']['totalCount'] == 0) { if ($result['Browse']['totalCount'] == 0) {
$page--; $page--;
$result = $db->alphabeticBrowse($source, $from, $page, $limit); $result = $db->alphabeticBrowse($source, $from, $page, $limit, $extraParams);
} }
// Only display next/previous page links when applicable: // Only display next/previous page links when applicable:
...@@ -108,6 +123,11 @@ class AlphabrowseController extends AbstractBase ...@@ -108,6 +123,11 @@ class AlphabrowseController extends AbstractBase
$view->alphaBrowseTypes = $types; $view->alphaBrowseTypes = $types;
$view->from = $from; $view->from = $from;
$view->source = $source; $view->source = $source;
// Pass information about extra columns on to theme
if (isset($extras[$source])) {
$view->extras = explode(':', $extras[$source]);
}
return $view; return $view;
} }
} }
\ No newline at end of file
...@@ -201,6 +201,13 @@ ul.cartContent { ...@@ -201,6 +201,13 @@ ul.cartContent {
background-color: #fff; background-color: #fff;
} }
.alphaBrowseExtra {
display: block;
float: left;
padding-left: .75em;
line-height: 1.31em;
}
.alphaBrowseForm { .alphaBrowseForm {
zoom: 1; zoom: 1;
} }
...@@ -211,6 +218,41 @@ ul.cartContent { ...@@ -211,6 +218,41 @@ ul.cartContent {
line-height: 1.31em; 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 { .alphaBrowseCount {
float: right; float: right;
} }
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
<div class="alphaBrowseHeader"><?=$this->transEsc("alphabrowse_matches") ?></div> <div class="alphaBrowseHeader"><?=$this->transEsc("alphabrowse_matches") ?></div>
<? foreach ($this->result['Browse']['items'] as $i => $item): ?> <? foreach ($this->result['Browse']['items'] as $i => $item): ?>
<div class="alphaBrowseEntry<? if ($i%2==1): echo ' alt'; endif; ?>"> <div class="alphaBrowseEntry<? if ($i%2==1): echo ' alt'; endif; ?> alphaBrowseSource_<?=$this->escapeHtml($this->source)?>">
<div class="alphaBrowseHeading"> <div class="alphaBrowseHeading alphaBrowseHeading_<?=$this->escapeHtml($this->source)?>">
<? if ($item['count'] > 0): ?> <? if ($item['count'] > 0): ?>
<?/* linking using bib ids is generally more reliable than <?/* linking using bib ids is generally more reliable than
doing searches for headings, but headings give shorter doing searches for headings, but headings give shorter
...@@ -56,6 +56,20 @@ ...@@ -56,6 +56,20 @@
<?=$this->escapeHtml($item['heading'])?> <?=$this->escapeHtml($item['heading'])?>
<? endif; ?> <? endif; ?>
</div> </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="alphaBrowseCount"><? if ($item['count'] > 0): echo $item['count']; endif; ?></div>
<div class="clear"></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