fix Search theme control so that it checks if search is enabled for site, and include AllowInput parameter to control input textbox
This commit is contained in:
parent
592255284f
commit
aba3110e31
|
@ -2,11 +2,14 @@
|
|||
@using System.Net
|
||||
@using Microsoft.AspNetCore.Http
|
||||
@inherits ThemeControlBase
|
||||
@inject ISettingService SettingService
|
||||
@inject IStringLocalizer<Search> Localizer
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@if (_searchResultsPage != null)
|
||||
{
|
||||
@if (AllowInput)
|
||||
{
|
||||
<span class="app-search @CssClass">
|
||||
<form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance>
|
||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||
|
@ -20,10 +23,18 @@
|
|||
</button>
|
||||
</form>
|
||||
</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post" class="app-form-inline" @formname="@($"SearchForm")" @onsubmit="@PerformSearch" data-enhance>
|
||||
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<span class="oi oi-magnifying-glass align-middle"></span>
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@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,11 +56,14 @@
|
|||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if(!string.IsNullOrEmpty(SearchResultPagePath))
|
||||
if (bool.Parse(SettingService.GetSetting(PageState.Site.Settings, "Search_Enabled", "True")))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(SearchResultPagePath))
|
||||
{
|
||||
_searchResultsPage = PageState.Pages.FirstOrDefault(i => i.Path == SearchResultPagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PerformSearch()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user