【发布时间】:2012-01-17 17:18:28
【问题描述】:
我的项目 (MVC3) N2CMS 2.2.1(来自 nuget)中有以下内容。我可以使用“管理部件”功能编辑主页,并将图像部件拖到页面上并设置其内容。但是,当它呈现页面时,它会在 _layout.cshtml 内呈现我的 Image.cshtml 文件(就像它用于页面,而不是一部分一样)......这导致网站有多个页眉/页脚等标签并破坏布局。我怎样才能让 DroppableZones 正确渲染局部(无需在每个局部视图中手动设置 Layout = "")。如果您想自己测试,可以查看https://github.com/robbihun/N2CMSBaseStarterSite 中的代码运行它,使用 sqlite db 完成 N2CMS 设置并使用管理部件功能 (http://screencast.com/t/w9q5a49Ei8)将图像部分拖到主页上。
_layout.cshtml
<body>
@{ Html.ControlPanel().Render(); }
@RenderBody()
<footer>© @DateTime.Now.Year</footer>
@RenderSection("scripts", false)
</body>
StartHome.cshtml
<div>
@{ Html.DroppableZone(Zones.ImageSlider).Render(); }
</div>
Image.cshtml
@model ImagePart
<div class="image">
<img src="@Model.Image" alt="@Model.Title" />
<span class="title">@Model.Title</span>
<span class="description">@Model.ShortDescription</span>
</div>
StartHomePage.cs
[PageDefinition("Start Page", Description = "The start or home page of the website.", SortOrder = 1, InstallerVisibility = InstallerHint.PreferredRootPage | InstallerHint.PreferredStartPage)]
[WithEditableTitle("Title", 1, Focus = true, ContainerName = Tabs.Content)]
[RestrictParents(typeof(IRootPage))]
public class StartHomePage : PageBase
{
[EditableFreeTextArea("Main Content", 2, ContainerName = Tabs.Content)]
public virtual string MainContent { get; set; }
}
ImagePart.cs
[PartDefinition("Image Part", Description = "Image with title and description.")]
[WithEditableTitle("Title", 10)]
public class ImagePart : PartBase
{
[FileAttachment, EditableImageUpload("Image", 5)]
public virtual string Image { get; set; }
[EditableTextBox("Short Description", 15, TextMode = TextBoxMode.MultiLine, Rows = 5, Columns = 15)]
public virtual string ShortDescription { get; set; }
}
【问题讨论】:
-
你能给我们截图吗?我在这里看不到重复的页眉/页脚。
-
看看这是否有助于让它更清晰一些 - 当我查看源代码时,我会得到额外的元标记和页脚标记(在我的 _layout.cshtml 文件中)screencast.com/t/Hw8ZUGKTOp4
-
我检查了你的 repo 并用 msbuild 编译 - 但我没有看到双页眉/页脚
标签: asp.net-mvc-3 n2cms