From 432aa8f4cfe0ebadaaf7010a228dc5a228f57b29 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Wed, 25 Mar 2015 11:37:28 -0400
Subject: [PATCH] Sort callnumber browse results on callnumber/dewey when
 viewed.

---
 module/VuFind/src/VuFind/Controller/BrowseController.php | 4 +++-
 themes/bootstrap3/templates/browse/home.phtml            | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/BrowseController.php b/module/VuFind/src/VuFind/Controller/BrowseController.php
index a7576dd4f4d..0b4adcf636d 100644
--- a/module/VuFind/src/VuFind/Controller/BrowseController.php
+++ b/module/VuFind/src/VuFind/Controller/BrowseController.php
@@ -356,7 +356,7 @@ class BrowseController extends AbstractBase
             'query_field' => 'callnumber-first',
             'facet_field' => 'callnumber-subject'
         ];
-        $view->searchParams = [];
+        $view->searchParams = ['sort' => 'callnumber-sort'];
         return $this->performSearch($view);
     }
 
@@ -378,6 +378,7 @@ class BrowseController extends AbstractBase
             ];
         }
         $view->categoryList = $categoryList;
+        $view->query_field = 'dewey';
         if ($this->params()->fromQuery('findby')) {
             $secondaryList = $this->quoteValues(
                 $this->getFacetList(
@@ -397,6 +398,7 @@ class BrowseController extends AbstractBase
                 'query_field' => 'dewey-tens',
                 'facet_field' => 'dewey-ones'
             ];
+            $view->searchParams = ['sort' => 'dewey-sort'];
         }
         return $this->performSearch($view);
     }
diff --git a/themes/bootstrap3/templates/browse/home.phtml b/themes/bootstrap3/templates/browse/home.phtml
index 4533145aa2d..fff3aed7b65 100644
--- a/themes/bootstrap3/templates/browse/home.phtml
+++ b/themes/bootstrap3/templates/browse/home.phtml
@@ -61,7 +61,7 @@
         <? endif; ?>
       </a>
       <? if($viewRecord): ?>
-        <a class="list-group-item view-record" href="<?=$SEARCH_BASE ?>?lookfor=<? if ($this->filter): ?>&filter[]=<?=urlencode($this->filter) ?>%3A<?=str_replace('+AND+','&filter[]=', urlencode($secondary['value'])) ?><? endif; ?>&filter[]=<?=$this->browse()->getSolrField($this->currentAction) ?>%3A[* TO *]"><?=$this->transEsc('View Records') ?></a>
+        <a class="list-group-item view-record" href="<?=$SEARCH_BASE ?>?lookfor=<? if ($this->filter): ?>&filter[]=<?=urlencode($this->filter) ?>%3A<?=str_replace('+AND+','&filter[]=', urlencode($secondary['value'])) ?><? endif; ?>&filter[]=<?=$this->browse()->getSolrField($this->currentAction) ?>%3A[* TO *]<? if($this->query_field == 'dewey'):?>&sort=dewey-sort<?endif;?>"><?=$this->transEsc('View Records') ?></a>
       <? endif; ?>
     <? endforeach; ?>
     </div>
-- 
GitLab