开发者

Can Wrappers in Orchard CMS have alternates?

I'm curious if I can somehow make the Widget.Wrapper shape (or other wrappers) alternateable, because it contains most of the widgets' HTML code. I don't like rich IF statements in cshtml files, therefore I'd rather use a clear solution using the alternates mechanism - being able to create alternates like these:

Widget.Wrapper-[ZoneName].cshtml
Widget.Wrapper-[WidgetId].cshtml
Widget.Wrapper-url-[UrlAlternate开发者_运维技巧].cshtml

etc.

Is that possible? Or are the wrappers a special case - and in that case why?

Thanks


Yes, it's possible. You can do it with IShapeTableProvider. Catch the shape that your widget it rendering, decide which wrapper you want, and then add a new wrapper.

builder.Describe("YourShapeHere")
    .OnDisplaying(displaying=>{
        displaying.ShapeMetadata.Wrappers.Add("Widget_Wrapper-" + displaying.Shape.Id);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜