mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
A search box for anyone.
- pulled the search box out into its own partial - added a search filter that sticks the search form partial into the search zone - added the search zone to the top of the classic theme's sidebar --HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Mvc.Filters;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Search.ViewModels;
|
||||
|
||||
namespace Orchard.Search.Filters {
|
||||
public class SearchFilter : FilterProvider, IResultFilter {
|
||||
public void OnResultExecuting(ResultExecutingContext filterContext) {
|
||||
var viewModel = filterContext.Controller.ViewData.Model as BaseViewModel;
|
||||
|
||||
if (viewModel != null)
|
||||
viewModel.Zones.AddRenderPartial("search", "SearchForm", viewModel is SearchViewModel ? viewModel : new SearchViewModel());
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext filterContext) {
|
||||
}
|
||||
}
|
||||
}
|
@@ -66,6 +66,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\SearchController.cs" />
|
||||
<Compile Include="Filters\SearchFilter.cs" />
|
||||
<Compile Include="Services\ISearchService.cs" />
|
||||
<Compile Include="Services\SearchService.cs" />
|
||||
<Compile Include="ViewModels\SearchResultViewModel.cs" />
|
||||
@@ -81,6 +82,7 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Styles\search.css" />
|
||||
<Content Include="Views\SearchForm.ascx" />
|
||||
<Content Include="Views\Search\Index.ascx" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
@@ -1,13 +1,9 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Search.ViewModels.SearchViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %><%
|
||||
Html.RegisterStyle("search.css"); %>
|
||||
<h1><%=Html.TitleForPage(T("Search"))%></h1><%
|
||||
using(Html.BeginForm("index", "search", FormMethod.Get, new { @class = "search" })) { %>
|
||||
<fieldset>
|
||||
<%=Html.TextBox("q", Model.Term) %>
|
||||
<button type="submit"><%=T("Search") %></button>
|
||||
</fieldset><%
|
||||
}
|
||||
<h1><%=Html.TitleForPage(T("Search"))%></h1>
|
||||
<%
|
||||
Html.Zone("search"); %><%
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Model.Term)) { %>
|
||||
<p class="search-summary"><%=T("<em>{0}</em> results", Model.Results.Count()) %></p><%
|
||||
|
@@ -0,0 +1,8 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<SearchViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Search.ViewModels" %><%
|
||||
using(Html.BeginForm("index", "search", new { area = "Orchard.Search" }, FormMethod.Get, new { @class = "search" })) { %>
|
||||
<fieldset>
|
||||
<%=Html.TextBox("q", Model.Term) %>
|
||||
<button type="submit"><%=T("Search") %></button>
|
||||
</fieldset><%
|
||||
} %>
|
@@ -62,7 +62,13 @@ input[type="text"], #CommentText, #password, #confirmPassword {
|
||||
padding:3px;
|
||||
width:90%;
|
||||
}
|
||||
|
||||
form.search {
|
||||
margin-bottom:2em;
|
||||
}
|
||||
.search input[type=text] {
|
||||
display:inline;
|
||||
width:17em;
|
||||
}
|
||||
fieldset div {margin:1.6em 0 0 0}
|
||||
|
||||
legend {
|
||||
|
@@ -33,7 +33,8 @@
|
||||
<%Html.ZoneBody("content");%>
|
||||
</div>
|
||||
<div id="sidebar">
|
||||
<%Html.Zone("sidebar");%>
|
||||
<% Html.Zone("search");
|
||||
Html.Zone("sidebar");%>
|
||||
</div>
|
||||
<%-- End Content --%>
|
||||
<% Html.Include("Footer"); %>
|
||||
|
Reference in New Issue
Block a user