Orchard Shape Wrapper

只谈情不闲聊 提交于 2019-12-12 03:23:28

问题


I'm following the Orchard documentation on Wrappers but couldn't wrap my head around it. http://docs.orchardproject.net/Documentation/Understanding-placement-info#Wrapper

According to the documentation, we were to create Wrapper.HtmlContent.cshtml and insert the following in it.

<div class="htmlWrapperContent">
    @Model.Html
</div>

But what is Model.Html? Is it a Shape? I know Model is the Shape itself. Html is not a built-in property of Shape or IShape so I figure it must be some custom property done through code, for example shapeHelper.My_Shape(Html: "Hello World")?


Let's start from the beginning with an illustration of what I'm trying to achieve. I have done the following:

Placement.info

<Placement>
    <Place My_Shape="Content:before;Wrapper=My_Wrapper" />
</Placement>

My.Shape.cshtml

<div class="myShape">
    @* let's pretend that the line below prints "Hello World" *@
    @Model.Html
</div>

My.Wrapper.cshtml

<div class="htmlWrapperContent">
    @* what should I be putting here? *@

    @* I have tried the following *@

    @* #1 *@
    <div class="myShape">
        @Model.Html
    </div>
    @* Obviously this works but then why would I use a wrapper to do this? I might as well just surround `My.Shape.cshtml` with `<div class="htmlWrapperContent"></div>` above. *@

    @* #2 *@
    @Display(Model)
    @* This doesn't work because circular reference. IIS killed itself. *@

    @* #3 *@
    @DisplayChildren(Model)
    @* Since `Model._items` is empty, this doesn't print anything. *@
</div>

My expectation of how the page should look like

<div class="htmlWrapperContent">
    <div class="myShape">
        Hello World
    </div>
</div>

So my question is, how should My.Wrapper.cshtml look like to meet my expectation?


回答1:


Shortly after posting my question, I found the answer here

Orchard - Wrappers for Fields

So, the wrapper should be

My.Wrapper.cshtml

<div class="htmlWrapperContent">
    @Display(Model.Metadata.ChildContent)
</div>

The Orchard documentation could use some improvements.



来源:https://stackoverflow.com/questions/35165911/orchard-shape-wrapper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!