0

我正在关注有关 Wrappers 的 Orchard 文档,但无法理解它。 http://docs.orchardproject.net/Documentation/Understanding-placement-info#Wrapper

根据文档,我们Wrapper.HtmlContent.cshtml将在其中创建并插入以下内容。

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

但什么是Model.Html?是Shape吗?我知道Model是形状本身。不是orHtml的内置属性,所以我认为它必须是通过代码完成的一些自定义属性,例如?ShapeIShapeshapeHelper.My_Shape(Html: "Hello World")


让我们从一开始就说明我正在努力实现的目标。我做了以下事情:

安置信息

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

我的.Shape.cshtml

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

我的.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>

我对页面外观的期望

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

所以我的问题是,应该如何My.Wrapper.cshtml满足我的期望?

4

1 回答 1

0

发布我的问题后不久,我在这里找到了答案

Orchard - 字段包装器

所以,包装应该是

我的.Wrapper.cshtml

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

Orchard 文档可以使用一些改进。

于 2016-02-03T08:01:14.710 回答