From 0bd844e139a0ce01fbbea68fcfe283f7836a0823 Mon Sep 17 00:00:00 2001 From: martimiz Date: Mon, 7 Jan 2013 16:53:33 +0100 Subject: [PATCH] Fix: no search results found on documentation homepage On the homepage there are no searchedEntities nor searchedVersions defined, so the searchForm creates empty hiddenfields. PerformSeach creates subqueries for thes empty values resulting in the return of an 'Empty' query object. Solution: do not create these fields when there are no entities/versions --- code/controllers/DocumentationViewer.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index d3f60ff..1a7bcb6 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -816,10 +816,19 @@ class DocumentationViewer extends Controller { if(!DocumentationSearch::enabled()) return false; $q = ($q = $this->getSearchQuery()) ? $q->NoHTML() : ""; + $entities = $this->getSearchedEntities(); + $versions = $this->getSearchedVersions(); + $fields = new FieldList( - new TextField('Search', _t('DocumentationViewer.SEARCH', 'Search'), $q), - new HiddenField('Entities', '', implode(',', array_keys($this->getSearchedEntities()))), - new HiddenField('Versions', '', implode(',', $this->getSearchedVersions())) + new TextField('Search', _t('DocumentationViewer.SEARCH', 'Search'), $q) + ); + + if ($entities) $fields->push( + new HiddenField('Entities', '', implode(',', array_keys($entities))) + ); + + if ($versions) $fields->push( + new HiddenField('Versions', '', implode(',', $versions)) ); $actions = new FieldList(