mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Supporting custom display type for search results
This commit is contained in:
@@ -73,7 +73,7 @@ namespace Orchard.Search.Controllers {
|
||||
// ignore search results which content item has been removed or unpublished
|
||||
var foundItems = _contentManager.GetMany<IContent>(foundIds, VersionOptions.Published, new QueryHints()).ToList();
|
||||
foreach (var contentItem in foundItems) {
|
||||
list.Add(_contentManager.BuildDisplay(contentItem, "Summary"));
|
||||
list.Add(_contentManager.BuildDisplay(contentItem, searchSettingPart.DisplayType));
|
||||
}
|
||||
searchHits.TotalItemCount -= foundIds.Count() - foundItems.Count();
|
||||
|
||||
|
@@ -34,11 +34,14 @@ namespace Orchard.Search.Drivers {
|
||||
var model = new SearchSettingsViewModel();
|
||||
var searchFields = part.SearchFields;
|
||||
|
||||
model.DisplayType = part.DisplayType;
|
||||
|
||||
if (updater != null) {
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
part.SearchIndex = model.SelectedIndex;
|
||||
part.SearchFields = model.Entries.ToDictionary(x => x.Index, x => x.Fields.Where(e => e.Selected).Select(e => e.Field).ToArray());
|
||||
part.FilterCulture = model.FilterCulture;
|
||||
part.DisplayType = model.DisplayType;
|
||||
}
|
||||
}
|
||||
else if (_indexManager.HasIndexProvider()) {
|
||||
|
@@ -24,5 +24,10 @@ namespace Orchard.Search.Models {
|
||||
get { return this.Retrieve(x => x.SearchIndex); }
|
||||
set { this.Store(x => x.SearchIndex, value); }
|
||||
}
|
||||
|
||||
public string DisplayType {
|
||||
get { return this.Retrieve(x => x.DisplayType, "Summary"); }
|
||||
set { this.Store(x => x.DisplayType, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ namespace Orchard.Search.ViewModels {
|
||||
public string SelectedIndex { get; set; }
|
||||
public IList<IndexSettingsEntry> Entries { get; set; }
|
||||
public bool FilterCulture { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
}
|
||||
|
||||
public class IndexSettingsEntry {
|
||||
|
@@ -57,5 +57,9 @@
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.FilterCulture)">@T("Narrow search to current culture only")</label>
|
||||
<span class="hint">@T("If checked, search results will only include content items localized in the current culture of the request.")</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="@Html.FieldIdFor(m => m.DisplayType)">@T("Display Type")</label>
|
||||
@Html.TextBoxFor(m => m.DisplayType, new { @class = "text single-line" })
|
||||
<span class="hint">@T("The display type to use for content items in the search results page.")</span>
|
||||
</div>
|
||||
</fieldset>
|
Reference in New Issue
Block a user