From 10aa4bb1deeb84f0093070620dcf504d9826e4a0 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 18 Dec 2012 10:49:34 -0500
Subject: [PATCH] Added support for top recommendations in collection module.

---
 config/vufind/Collection.ini                              | 5 +++++
 module/VuFind/src/VuFind/RecordTab/CollectionList.php     | 1 +
 module/VuFind/src/VuFind/Search/SolrCollection/Params.php | 7 +++++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/config/vufind/Collection.ini b/config/vufind/Collection.ini
index b3c83391750..55338e814a2 100644
--- a/config/vufind/Collection.ini
+++ b/config/vufind/Collection.ini
@@ -1,6 +1,11 @@
 ; This file controls the Collection module (the page accessed by viewing a record
 ; which is a collection).
 
+; These settings control the top and side recommendations (see searches.ini for
+; details on recommendation modules).
+[Recommend]
+;top[] = "PubDateVisAjax:true:publishDate"
+
 ; These settings control which fields are available to sort on in the Collection
 ; module.
 [Sort]
diff --git a/module/VuFind/src/VuFind/RecordTab/CollectionList.php b/module/VuFind/src/VuFind/RecordTab/CollectionList.php
index 045ba180ba0..41076b4a21a 100644
--- a/module/VuFind/src/VuFind/RecordTab/CollectionList.php
+++ b/module/VuFind/src/VuFind/RecordTab/CollectionList.php
@@ -87,6 +87,7 @@ class CollectionList extends AbstractBase
             $this->results->getParams()->initFromRecordDriver(
                 $this->getRecordDriver(), $params
             );
+            $this->results->getParams()->recommendationsEnabled(true);
             $this->processed = true;
         }
         return $this->results;
diff --git a/module/VuFind/src/VuFind/Search/SolrCollection/Params.php b/module/VuFind/src/VuFind/Search/SolrCollection/Params.php
index ec6787958be..22b9972f22b 100644
--- a/module/VuFind/src/VuFind/Search/SolrCollection/Params.php
+++ b/module/VuFind/src/VuFind/Search/SolrCollection/Params.php
@@ -118,7 +118,10 @@ class Params extends \VuFind\Search\Solr\Params
      */
     protected function getRecommendationSettings()
     {
-        // Disabled for now
-        return array();
+        // Collection recommendations
+        $searchSettings = \VuFind\Config\Reader::getConfig('Collection');
+        return isset($searchSettings->Recommend)
+            ? $searchSettings->Recommend->toArray()
+            : array();
     }
 }
\ No newline at end of file
-- 
GitLab