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.ContentManagement;
|
||||||
using Orchard.Search.Services;
|
using Orchard.Search.Services;
|
||||||
using Orchard.Search.ViewModels;
|
using Orchard.Search.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.Search.Controllers {
|
namespace Orchard.Search.Controllers {
|
||||||
|
[ValidateInput(false)]
|
||||||
public class SearchController : Controller {
|
public class SearchController : Controller {
|
||||||
private readonly ISearchService _searchService;
|
private readonly ISearchService _searchService;
|
||||||
private readonly IContentManager _contentManager;
|
private readonly IContentManager _contentManager;
|
||||||
@@ -14,15 +14,16 @@ namespace Orchard.Search.Controllers {
|
|||||||
_contentManager = contentManager;
|
_contentManager = contentManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Index(string term) {
|
public ActionResult Index(string q) {
|
||||||
var results = _searchService.Query(term);
|
var searchViewModel = new SearchViewModel {Term = q};
|
||||||
return View(new SearchViewModel {
|
|
||||||
Term = term,
|
var results = _searchService.Query(q);
|
||||||
Results = results.Select(result => new SearchResultViewModel {
|
searchViewModel.Results = results.Select(result => new SearchResultViewModel {
|
||||||
Content = _contentManager.BuildDisplayModel(_contentManager.Get(result.Id), "SummaryForSearch"),
|
Content = _contentManager.BuildDisplayModel(_contentManager.Get(result.Id), "SummaryForSearch"),
|
||||||
SearchHit = result
|
SearchHit = result
|
||||||
}).ToList()
|
}).ToList();
|
||||||
});
|
|
||||||
|
return View(searchViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,7 +4,7 @@ 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" })) { %>
|
using(Html.BeginForm("index", "search", FormMethod.Get, new { @class = "search" })) { %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<%=Html.TextBoxFor(m => m.Term) %>
|
<%=Html.TextBox("q", Model.Term) %>
|
||||||
<button type="submit"><%=T("Search") %></button>
|
<button type="submit"><%=T("Search") %></button>
|
||||||
</fieldset><%
|
</fieldset><%
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user