mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-08-01 17:51:18 +08:00
Merge pull request #5640 from jtkech/patch-4
#5552: ContentPicker Search Route issue Fixes #5552
This commit is contained in:
commit
73683ec057
@ -47,8 +47,6 @@ namespace Orchard.Search.Controllers {
|
|||||||
public ActionResult Index(PagerParameters pagerParameters, string part, string field, string searchText = "") {
|
public ActionResult Index(PagerParameters pagerParameters, string part, string field, string searchText = "") {
|
||||||
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||||
var searchSettingsPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
|
var searchSettingsPart = Services.WorkContext.CurrentSite.As<SearchSettingsPart>();
|
||||||
var searchIndex = searchSettingsPart.SearchIndex;
|
|
||||||
var searchFields = searchSettingsPart.GetSearchFields(searchSettingsPart.SearchIndex);
|
|
||||||
var totalCount = 0;
|
var totalCount = 0;
|
||||||
var foundIds = new int[0];
|
var foundIds = new int[0];
|
||||||
|
|
||||||
@ -66,6 +64,11 @@ namespace Orchard.Search.Controllers {
|
|||||||
return View("NoIndex");
|
return View("NoIndex");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var searchIndex = searchSettingsPart.SearchIndex;
|
||||||
|
if (settings != null && !String.IsNullOrEmpty(settings.SearchIndex))
|
||||||
|
searchIndex = settings.SearchIndex;
|
||||||
|
var searchFields = searchSettingsPart.GetSearchFields(searchIndex);
|
||||||
|
|
||||||
var builder = _indexManager.GetSearchIndexProvider().CreateSearchBuilder(searchIndex);
|
var builder = _indexManager.GetSearchIndexProvider().CreateSearchBuilder(searchIndex);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -75,12 +78,12 @@ namespace Orchard.Search.Controllers {
|
|||||||
var rawTypes = settings.DisplayedContentTypes.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
var rawTypes = settings.DisplayedContentTypes.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
var contentTypes = _contentDefinitionManager
|
var contentTypes = _contentDefinitionManager
|
||||||
.ListTypeDefinitions()
|
.ListTypeDefinitions()
|
||||||
.Where(x => x.Parts.Any(p => rawTypes.Contains(p.PartDefinition.Name)))
|
.Where(x => x.Parts.Any(p => rawTypes.Contains(p.PartDefinition.Name)) || rawTypes.Contains(x.Name))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
|
||||||
foreach (string type in contentTypes.Select(x => x.Name)) {
|
foreach (string type in contentTypes.Select(x => x.Name)) {
|
||||||
builder.WithField("type", type).AsFilter();
|
builder.WithField("type", type).NotAnalyzed().AsFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,4 +127,4 @@ namespace Orchard.Search.Controllers {
|
|||||||
return new ShapeResult(this, Services.New.ContentPicker().Tab(tab));
|
return new ShapeResult(this, Services.New.ContentPicker().Tab(tab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace Orchard.Search.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(mediaType)) {
|
if (!String.IsNullOrEmpty(mediaType)) {
|
||||||
builder.WithField("type", mediaType).Mandatory().AsFilter();
|
builder.WithField("type", mediaType).NotAnalyzed().AsFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(folderPath)) {
|
if (!String.IsNullOrEmpty(folderPath)) {
|
||||||
|
@ -13,6 +13,20 @@ namespace Orchard.Search {
|
|||||||
|
|
||||||
public IEnumerable<RouteDescriptor> GetRoutes() {
|
public IEnumerable<RouteDescriptor> GetRoutes() {
|
||||||
return new[] {
|
return new[] {
|
||||||
|
new RouteDescriptor {
|
||||||
|
Priority = 5,
|
||||||
|
Route = new Route("Search/ContentPicker",
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Search"},
|
||||||
|
{"controller", "ContentPicker"},
|
||||||
|
{"action", "Index"}
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
new RouteValueDictionary {
|
||||||
|
{"area", "Orchard.Search"}
|
||||||
|
},
|
||||||
|
new MvcRouteHandler())
|
||||||
|
},
|
||||||
new RouteDescriptor {
|
new RouteDescriptor {
|
||||||
Priority = 5,
|
Priority = 5,
|
||||||
Route = new Route("Search/{searchIndex}",
|
Route = new Route("Search/{searchIndex}",
|
||||||
@ -31,4 +45,4 @@ namespace Orchard.Search {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user