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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controllers\SearchController.cs" />
|
<Compile Include="Controllers\SearchController.cs" />
|
||||||
|
<Compile Include="Filters\SearchFilter.cs" />
|
||||||
<Compile Include="Services\ISearchService.cs" />
|
<Compile Include="Services\ISearchService.cs" />
|
||||||
<Compile Include="Services\SearchService.cs" />
|
<Compile Include="Services\SearchService.cs" />
|
||||||
<Compile Include="ViewModels\SearchResultViewModel.cs" />
|
<Compile Include="ViewModels\SearchResultViewModel.cs" />
|
||||||
@@ -81,6 +82,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
<Content Include="Styles\search.css" />
|
<Content Include="Styles\search.css" />
|
||||||
|
<Content Include="Views\SearchForm.ascx" />
|
||||||
<Content Include="Views\Search\Index.ascx" />
|
<Content Include="Views\Search\Index.ascx" />
|
||||||
<Content Include="Views\Web.config" />
|
<Content Include="Views\Web.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Search.ViewModels.SearchViewModel>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Search.ViewModels.SearchViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html" %><%
|
<%@ Import Namespace="Orchard.Mvc.Html" %><%
|
||||||
Html.RegisterStyle("search.css"); %>
|
Html.RegisterStyle("search.css"); %>
|
||||||
<h1><%=Html.TitleForPage(T("Search"))%></h1><%
|
<h1><%=Html.TitleForPage(T("Search"))%></h1>
|
||||||
using(Html.BeginForm("index", "search", FormMethod.Get, new { @class = "search" })) { %>
|
<%
|
||||||
<fieldset>
|
Html.Zone("search"); %><%
|
||||||
<%=Html.TextBox("q", Model.Term) %>
|
|
||||||
<button type="submit"><%=T("Search") %></button>
|
|
||||||
</fieldset><%
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(Model.Term)) { %>
|
if (!string.IsNullOrWhiteSpace(Model.Term)) { %>
|
||||||
<p class="search-summary"><%=T("<em>{0}</em> results", Model.Results.Count()) %></p><%
|
<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><%
|
||||||
|
} %>
|
@@ -61,8 +61,14 @@ input[type="text"], #CommentText, #password, #confirmPassword {
|
|||||||
display: block;
|
display: block;
|
||||||
padding:3px;
|
padding:3px;
|
||||||
width:90%;
|
width:90%;
|
||||||
}
|
}
|
||||||
|
form.search {
|
||||||
|
margin-bottom:2em;
|
||||||
|
}
|
||||||
|
.search input[type=text] {
|
||||||
|
display:inline;
|
||||||
|
width:17em;
|
||||||
|
}
|
||||||
fieldset div {margin:1.6em 0 0 0}
|
fieldset div {margin:1.6em 0 0 0}
|
||||||
|
|
||||||
legend {
|
legend {
|
||||||
|
@@ -33,7 +33,8 @@
|
|||||||
<%Html.ZoneBody("content");%>
|
<%Html.ZoneBody("content");%>
|
||||||
</div>
|
</div>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<%Html.Zone("sidebar");%>
|
<% Html.Zone("search");
|
||||||
|
Html.Zone("sidebar");%>
|
||||||
</div>
|
</div>
|
||||||
<%-- End Content --%>
|
<%-- End Content --%>
|
||||||
<% Html.Include("Footer"); %>
|
<% Html.Include("Footer"); %>
|
||||||
|
Reference in New Issue
Block a user