mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Adding some widget wrapper auto-classification
--HG-- branch : dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Widgets.Models;
|
||||
|
||||
namespace Orchard.Widgets {
|
||||
@@ -16,8 +17,13 @@ namespace Orchard.Widgets {
|
||||
widget.Child.Add(created.New.PlaceChildContent(Source: widget));
|
||||
})
|
||||
.OnDisplaying(displaying => {
|
||||
var widget = displaying.Shape;
|
||||
widget.Classes.Add("widget");
|
||||
|
||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||
if (contentItem != null) {
|
||||
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
|
||||
|
||||
var zoneName = contentItem.As<WidgetPart>().Zone;
|
||||
displaying.ShapeMetadata.Alternates.Add("Widget__" + contentItem.ContentType);
|
||||
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);
|
||||
|
@@ -2,8 +2,9 @@
|
||||
@using Orchard.Widgets.Models;
|
||||
@{
|
||||
var title = ((IContent)Model.ContentItem).As<WidgetPart>().Title;
|
||||
var tag = Tag(Model, "article");
|
||||
}
|
||||
<article class="widget">
|
||||
@tag.StartElement
|
||||
<header>
|
||||
<h1>@title</h1>
|
||||
@Display(Model.Header)
|
||||
@@ -14,4 +15,4 @@
|
||||
@Display(Model.Footer)
|
||||
</footer>
|
||||
}
|
||||
</article>
|
||||
@tag.EndElement
|
Reference in New Issue
Block a user