mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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.ContentManagement;
|
||||||
using Orchard.DisplayManagement.Descriptors;
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
|
using Orchard.Utility.Extensions;
|
||||||
using Orchard.Widgets.Models;
|
using Orchard.Widgets.Models;
|
||||||
|
|
||||||
namespace Orchard.Widgets {
|
namespace Orchard.Widgets {
|
||||||
@@ -16,8 +17,13 @@ namespace Orchard.Widgets {
|
|||||||
widget.Child.Add(created.New.PlaceChildContent(Source: widget));
|
widget.Child.Add(created.New.PlaceChildContent(Source: widget));
|
||||||
})
|
})
|
||||||
.OnDisplaying(displaying => {
|
.OnDisplaying(displaying => {
|
||||||
|
var widget = displaying.Shape;
|
||||||
|
widget.Classes.Add("widget");
|
||||||
|
|
||||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||||
if (contentItem != null) {
|
if (contentItem != null) {
|
||||||
|
widget.Classes.Add("widget-" + contentItem.ContentType.HtmlClassify());
|
||||||
|
|
||||||
var zoneName = contentItem.As<WidgetPart>().Zone;
|
var zoneName = contentItem.As<WidgetPart>().Zone;
|
||||||
displaying.ShapeMetadata.Alternates.Add("Widget__" + contentItem.ContentType);
|
displaying.ShapeMetadata.Alternates.Add("Widget__" + contentItem.ContentType);
|
||||||
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);
|
displaying.ShapeMetadata.Alternates.Add("Widget__" + zoneName);
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
@using Orchard.Widgets.Models;
|
@using Orchard.Widgets.Models;
|
||||||
@{
|
@{
|
||||||
var title = ((IContent)Model.ContentItem).As<WidgetPart>().Title;
|
var title = ((IContent)Model.ContentItem).As<WidgetPart>().Title;
|
||||||
|
var tag = Tag(Model, "article");
|
||||||
}
|
}
|
||||||
<article class="widget">
|
@tag.StartElement
|
||||||
<header>
|
<header>
|
||||||
<h1>@title</h1>
|
<h1>@title</h1>
|
||||||
@Display(Model.Header)
|
@Display(Model.Header)
|
||||||
@@ -14,4 +15,4 @@
|
|||||||
@Display(Model.Footer)
|
@Display(Model.Footer)
|
||||||
</footer>
|
</footer>
|
||||||
}
|
}
|
||||||
</article>
|
@tag.EndElement
|
||||||
Reference in New Issue
Block a user