From aba3110e317744eebd4f465a4ae4c8a4b47cee60 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Mon, 26 Aug 2024 10:41:22 -0400 Subject: [PATCH] fix Search theme control so that it checks if search is enabled for site, and include AllowInput parameter to control input textbox --- .../Themes/Controls/Theme/Search.razor | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/Oqtane.Client/Themes/Controls/Theme/Search.razor b/Oqtane.Client/Themes/Controls/Theme/Search.razor index 0d8ebb51..b6816a90 100644 --- a/Oqtane.Client/Themes/Controls/Theme/Search.razor +++ b/Oqtane.Client/Themes/Controls/Theme/Search.razor @@ -2,28 +2,39 @@ @using System.Net @using Microsoft.AspNetCore.Http @inherits ThemeControlBase +@inject ISettingService SettingService @inject IStringLocalizer Localizer @inject NavigationManager NavigationManager @if (_searchResultsPage != null) { - + @if (AllowInput) + { + +
+ + + +
+
+ } + else + {
- -
-
+ } } - - @code { private Page _searchResultsPage; private string _keywords = ""; @@ -32,7 +43,10 @@ public string CssClass { get; set; } [Parameter] - public string SearchResultPagePath { get; set; } = "search"; + public bool AllowInput { get; set; } = true; // setting to false will display only the search icon button - not the textbox + + [Parameter] + public string SearchResultPagePath { get; set; } = "search"; // setting to "" will disable search [CascadingParameter] HttpContext HttpContext { get; set; } @@ -42,9 +56,12 @@ protected override void OnInitialized() { - if(!string.IsNullOrEmpty(SearchResultPagePath)) + if (bool.Parse(SettingService.GetSetting(PageState.Site.Settings, "Search_Enabled", "True"))) { - _searchResultsPage = PageState.Pages.FirstOrDefault(i => i.Path == SearchResultPagePath); + if (!string.IsNullOrEmpty(SearchResultPagePath)) + { + _searchResultsPage = PageState.Pages.FirstOrDefault(i => i.Path == SearchResultPagePath); + } } }