果园形状包装器 [英] Orchard Shape Wrapper
问题描述
我正在关注有关 Wrappers 的 Orchard 文档,但无法理解它.http://docs.orchardproject.net/Documentation/Understanding-placement-info#Wrapper
根据文档,我们要创建 Wrapper.HtmlContent.cshtml
并在其中插入以下内容.
@Model.Html
但是什么是Model.Html
?它是 Shape
吗?我知道 Model
是 Shape 本身.Html
不是 Shape
或 IShape
的内置属性,所以我认为它必须是通过代码完成的一些自定义属性,例如 shapeHelper.My_Shape(Html: "Hello World")
?
让我们从头开始,举例说明我正在努力实现的目标.我做了以下事情:
Placement.info
<Place My_Shape="Content:before;Wrapper=My_Wrapper"/></展示位置>
My.Shape.cshtml
@* 让我们假设下面的行打印Hello World"*@@Model.Html
My.Wrapper.cshtml
@* 我应该在这里放什么?*@@* 我已经尝试了以下 *@@* #1 *@<div class="myShape">@Model.Html@* 显然这是有效的,但为什么我要使用包装器来做到这一点?我不妨用上面的 `<div class="htmlWrapperContent"></div>` 将 `My.Shape.cshtml` 括起来.*@@* #2 *@@显示(模型)@* 这不起作用,因为循环引用.IIS 自杀了.*@@* #3 *@@DisplayChildren(模型)@* 因为`Model._items` 是空的,这不会打印任何东西.*@
我对页面外观的期望
<div class="myShape">你好,世界
所以我的问题是,My.Wrapper.cshtml
应该如何满足我的期望?
发布我的问题后不久,我在这里找到了答案
所以,包装器应该是
My.Wrapper.cshtml
@Display(Model.Metadata.ChildContent)
Orchard 文档可以进行一些改进.
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?
Shortly after posting my question, I found the answer here
So, the wrapper should be
My.Wrapper.cshtml
<div class="htmlWrapperContent">
@Display(Model.Metadata.ChildContent)
</div>
The Orchard documentation could use some improvements.
这篇关于果园形状包装器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!