mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
30 lines
1.3 KiB
C#
30 lines
1.3 KiB
C#
using Orchard.ContentManagement;
|
|
using Orchard.DisplayManagement.Descriptors;
|
|
using Orchard.Widgets.Models;
|
|
|
|
namespace Orchard.Widgets {
|
|
public class Shapes : IShapeTableProvider {
|
|
public void Discover(ShapeTableBuilder builder) {
|
|
builder.Describe("Items_Widget")
|
|
.Configure(descriptor => {
|
|
// todo: have "alternates" for chrome
|
|
//todo: (heskew) something...this still doesn't feel right
|
|
descriptor.Wrappers.Add("Widget_ControlWrapper");
|
|
descriptor.Wrappers.Add("Widget_Wrapper");
|
|
})
|
|
.OnCreated(created => {
|
|
var widget = created.Shape;
|
|
widget.Main.Add(created.New.PlaceChildContent(Source: widget));
|
|
})
|
|
.OnDisplaying(displaying => {
|
|
ContentItem contentItem = displaying.Shape.ContentItem;
|
|
if (contentItem != null) {
|
|
var zoneName = contentItem.As<WidgetPart>().Zone;
|
|
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + contentItem.ContentType);
|
|
displaying.ShapeMetadata.Alternates.Add("Items_Widget__" + zoneName);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|