mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#18548: Fixing custom DisplayText metadata
Work Item: 18548 --HG-- branch : 1.x
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Handlers;
|
||||||
using Orchard.Core.Title.Models;
|
using Orchard.Core.Title.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
|
|
||||||
@@ -7,6 +8,15 @@ namespace Orchard.Core.Title.Handlers {
|
|||||||
|
|
||||||
public TitlePartHandler(IRepository<TitlePartRecord> repository) {
|
public TitlePartHandler(IRepository<TitlePartRecord> repository) {
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
|
OnIndexing<TitlePart>((context, part) => context.DocumentIndex.Add("title", part.Title).RemoveTags().Analyze());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
|
var part = context.ContentItem.As<TitlePart>();
|
||||||
|
|
||||||
|
if (part != null) {
|
||||||
|
context.Metadata.DisplayText = part.Title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
using Orchard.ContentManagement.Handlers;
|
using Orchard.ContentManagement.Handlers;
|
||||||
|
using Orchard.Core.Title.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
|
|
||||||
@@ -11,7 +12,8 @@ namespace Orchard.Widgets.Handlers {
|
|||||||
public WidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
|
public WidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
|
||||||
Filters.Add(StorageFilter.For(widgetsRepository));
|
Filters.Add(StorageFilter.For(widgetsRepository));
|
||||||
|
|
||||||
OnInitializing<WidgetPart>((context, part) => part.RenderTitle = true);
|
OnInitializing<WidgetPart>((context, part) => part.RenderTitle = true);
|
||||||
|
OnIndexing<TitlePart>((context, part) => context.DocumentIndex.Add("title", part.Title).RemoveTags().Analyze());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||||
@@ -20,6 +22,8 @@ namespace Orchard.Widgets.Handlers {
|
|||||||
if (widget == null)
|
if (widget == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
context.Metadata.DisplayText = widget.Title;
|
||||||
|
|
||||||
// create needs to go through the add widget flow (index -> [select layer -> ] add [widget type] to layer)
|
// create needs to go through the add widget flow (index -> [select layer -> ] add [widget type] to layer)
|
||||||
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
||||||
{"Area", "Orchard.Widgets"},
|
{"Area", "Orchard.Widgets"},
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
using Orchard.ContentManagement.Aspects;
|
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Handlers {
|
|
||||||
public class TitlePartHandler : ContentHandler {
|
|
||||||
|
|
||||||
public TitlePartHandler() {
|
|
||||||
OnIndexing<ITitleAspect>((context, part) => context.DocumentIndex.Add("title", part.Title).RemoveTags().Analyze());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
|
||||||
var part = context.ContentItem.As<ITitleAspect>();
|
|
||||||
|
|
||||||
if (part != null) {
|
|
||||||
context.Metadata.DisplayText = part.Title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -161,7 +161,6 @@
|
|||||||
<Compile Include="ContentManagement\Handlers\BuildShapeContext.cs" />
|
<Compile Include="ContentManagement\Handlers\BuildShapeContext.cs" />
|
||||||
<Compile Include="ContentManagement\Handlers\ExportContentContext.cs" />
|
<Compile Include="ContentManagement\Handlers\ExportContentContext.cs" />
|
||||||
<Compile Include="ContentManagement\Handlers\ImportContentContext.cs" />
|
<Compile Include="ContentManagement\Handlers\ImportContentContext.cs" />
|
||||||
<Compile Include="ContentManagement\Handlers\TitleAspectHandler.cs" />
|
|
||||||
<Compile Include="ContentManagement\IContentBehavior.cs" />
|
<Compile Include="ContentManagement\IContentBehavior.cs" />
|
||||||
<Compile Include="ContentManagement\ImportContentSession.cs" />
|
<Compile Include="ContentManagement\ImportContentSession.cs" />
|
||||||
<Compile Include="ContentManagement\MetaData\Services\ISettingsFormatter.cs" />
|
<Compile Include="ContentManagement\MetaData\Services\ISettingsFormatter.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user