mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Enhancement: allow for enabling/disabling advanced search
The advanced searchbox only really functions properly for multiple entities if they all have similar versions. If not, it will let you search on entity-version combinations that might not even exist, which can get confusing.. In such cases optionally disabling it could be a solution, waiting for a better solution (possibly
This commit is contained in:
parent
0bd844e139
commit
9f1f70a065
@ -30,6 +30,11 @@ class DocumentationSearch {
|
||||
* @var bool - Is search enabled
|
||||
*/
|
||||
private static $enabled = false;
|
||||
|
||||
/**
|
||||
* @var bool - Is advanced search enabled
|
||||
*/
|
||||
private static $advanced_search_enabled = true;
|
||||
|
||||
/**
|
||||
* @var string - OpenSearch metadata. Please use {@link DocumentationSearch::set_meta_data()}
|
||||
@ -171,6 +176,20 @@ class DocumentationSearch {
|
||||
return self::$enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable advanced documentation search
|
||||
*/
|
||||
public static function enable_advanced_search($enabled = true) {
|
||||
self::$advanced_search_enabled = ($enabled)? true: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function advanced_search_enabled() {
|
||||
return self::$advanced_search_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
|
@ -973,6 +973,17 @@ class DocumentationViewer extends Controller {
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the Advanced SearchForm can be displayed
|
||||
* enabled by default, to disable use:
|
||||
* DocumentationSearch::enable_advanced_search(false);
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getAdvancedSearchEnabled() {
|
||||
return DocumentationSearch::advanced_search_enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the currently accessed version is out of date or
|
||||
|
@ -65,6 +65,13 @@ documentation search needs to be updated on the fly
|
||||
|
||||
sake dev/tasks/RebuildLuceneDocsIndex flush=1
|
||||
|
||||
## Advanced Search
|
||||
|
||||
Advanced Search is enabled by default on the searchresults page, allowing you to
|
||||
extend your search over multiple modules and/or versions. Advanced search can
|
||||
be disabled from your _config.php like this:
|
||||
|
||||
DocumentationSearch::enable_advanced_search(false);
|
||||
|
||||
## Using a URL other than /dev/docs/
|
||||
|
||||
|
@ -43,10 +43,13 @@
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
||||
<div id="sidebar-column">
|
||||
<div class="sidebar-box">
|
||||
<h4><% _t('ADVANCEDSEARCH', 'Advanced Search') %></h4>
|
||||
$AdvancedSearchForm
|
||||
<% if AdvancedSearchEnabled %>
|
||||
<div id="sidebar-column">
|
||||
<div class="sidebar-box">
|
||||
<h4><% _t('ADVANCEDSEARCH', 'Advanced Search') %></h4>
|
||||
$AdvancedSearchForm
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user