mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Changed query param name for search to 'q' from 'Term'
- also flipped ValidateInput for the controller off and tweaked the action for easier reading --HG-- branch : dev
This commit is contained in:
@@ -3,8 +3,8 @@ using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Search.Services;
|
||||
using Orchard.Search.ViewModels;
|
||||
|
||||
namespace Orchard.Search.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class SearchController : Controller {
|
||||
private readonly ISearchService _searchService;
|
||||
private readonly IContentManager _contentManager;
|
||||
@@ -14,15 +14,16 @@ namespace Orchard.Search.Controllers {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public ActionResult Index(string term) {
|
||||
var results = _searchService.Query(term);
|
||||
return View(new SearchViewModel {
|
||||
Term = term,
|
||||
Results = results.Select(result => new SearchResultViewModel {
|
||||
Content = _contentManager.BuildDisplayModel(_contentManager.Get(result.Id), "SummaryForSearch"),
|
||||
SearchHit = result
|
||||
}).ToList()
|
||||
});
|
||||
public ActionResult Index(string q) {
|
||||
var searchViewModel = new SearchViewModel {Term = q};
|
||||
|
||||
var results = _searchService.Query(q);
|
||||
searchViewModel.Results = results.Select(result => new SearchResultViewModel {
|
||||
Content = _contentManager.BuildDisplayModel(_contentManager.Get(result.Id), "SummaryForSearch"),
|
||||
SearchHit = result
|
||||
}).ToList();
|
||||
|
||||
return View(searchViewModel);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ Html.RegisterStyle("search.css"); %>
|
||||
<h1><%=Html.TitleForPage(T("Search"))%></h1><%
|
||||
using(Html.BeginForm("index", "search", FormMethod.Get, new { @class = "search" })) { %>
|
||||
<fieldset>
|
||||
<%=Html.TextBoxFor(m => m.Term) %>
|
||||
<%=Html.TextBox("q", Model.Term) %>
|
||||
<button type="submit"><%=T("Search") %></button>
|
||||
</fieldset><%
|
||||
}
|
||||
|
Reference in New Issue
Block a user