【问题标题】:Field placement when editing items in N2 cms?以 N2 cms 编辑项目时的字段放置?
【发布时间】:2011-03-11 11:55:16
【问题描述】:

在 N2 CMS 上工作,我正在添加自己的内容类型 Product。我从 ContentPageBase 派生了我的 Product 类,我可以将它添加到内容树中。然而,当我编辑一个项目时,这些字段似乎是反转的(TitleText)。对于所有示例项目(例如News),Title 始终显示在顶部。

我知道有一个 ContainerName 属性可以设置为 tabname,但是我在 @ 中没有看到 TitleText 的任何属性覆盖987654332@class,怎么会这样呢?

编辑新闻项目

编辑产品

Product.cs(自定义)

using N2;
using N2.Web;
using N2.Details;
using N2.Integrity;

namespace N2.Templates.Mvc.Models.Pages
{
  /// <summary>
  /// This class represents the data transfer object that encapsulates 
  /// the information used by the template.
  /// </summary>
  [PageDefinition("Product")]
  [WithEditableTitle, WithEditableName]
  [RestrictParents(typeof(ProductSection),typeof(ProductCategory))]
  public class Product : ContentPageBase
  {

  }
}

News.cs(默认)

using System.Web.UI.WebControls;
using N2.Definitions;
using N2.Details;
using N2.Integrity;
using N2.Templates.Mvc.Services;
using N2.Web.Mvc;
using N2.Persistence;

namespace N2.Templates.Mvc.Models.Pages
{
    [PageDefinition("News", Description = "A news page.", SortOrder = 155,
        IconUrl = "~/Content/Img/newspaper.png")]
    [RestrictParents(typeof (NewsContainer))]
    public class News : ContentPageBase, ISyndicatable
    {
        public News()
        {
            Visible = false;
            Syndicate = true;
        }

        [EditableTextBox("Introduction", 90, ContainerName = Tabs.Content, TextMode = TextBoxMode.MultiLine, Rows = 4,
            Columns = 80)]
        public virtual string Introduction
        {
            get { return (string) (GetDetail("Introduction") ?? string.Empty); }
            set { SetDetail("Introduction", value, string.Empty); }
        }

        string ISyndicatable.Summary
        {
            get { return Introduction; }
        }

        [Persistable(PersistAs = PropertyPersistenceLocation.Detail)]
        public virtual bool Syndicate { get; set; }
    }
}

【问题讨论】:

    标签: asp.net-mvc n2 n2cms


    【解决方案1】:

    标题和名称编辑器不是在属性本身上设置的,而是在类上设置的。

    查看您班级的WithEditableTitleWithEditableName 属性。

    而且 News 类不必指定它们,因为它继承自 ContentPageBase 而不是您的 Product 类正在使用的根 ContentItem 类。 ContentPageBase 已经指定了 Title 和 Name 编辑器,因此 News 不必再次指定。

    【讨论】:

    • 你说得对,我在 Product 上再次指定它们,使 N2 将它们放在下面!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多