1

私のプロジェクト(MVC3)N2CMS 2.2.1(nugetから)には次のものがあります。「パーツの管理」機能を使用してメイン ページを編集し、画像パーツをページにドラッグしてコンテンツを設定することができます。ただし、ページをレンダリングすると、Image.cshtmlファイルが_layout.cshtml内にレンダリングされます(一部ではなくページの場合と同様)...これにより、サイトに複数のヘッド/フッターなどのタグがあり、破損していますレイアウト。DroppableZones でパーシャルを適切にレンダリングするにはどうすればよいですか (すべてのパーシャル ビューで Layout = "" を手動で設定する必要はありません)。これを自分でテストしたい場合は、https://github.com/robbihun/N2CMSBaseStarterSiteからコードを確認できます。それを実行し、sqlite db を使用して N2CMS セットアップを行い、パーツの管理機能 (http://screencast.com/t/w9q5a49Ei8) を使用して画像パーツをホームページにドラッグします。

_layout.cshtml

<body>
    @{ Html.ControlPanel().Render(); }
    @RenderBody()

    <footer>&copy; @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; }
}
4

1 に答える 1

0

Views/Shared/Parts フォルダーに _ViewStart.cshtml を追加すると、そのフォルダーのレイアウト設定が上書きされます。新しい _ViewStart ではLayout = null;、部分ビューでレイアウトを設定し、設定しないでください。

こちらがプルリクエストです: https://github.com/robbihun/N2CMSBaseStarterSite/pull/1

于 2012-01-17T19:27:56.723 に答える