在 N2 cms 中编辑项目时的现场放置?

发布于 2024-10-21 10:09:46 字数 2253 浏览 8 评论 0原文

在 N2 CMS 上工作时,我添加了自己的内容类型 Product。我从 ContentPageBase 派生我的 Product 类,并且可以将其添加到内容树中。但是,当我编辑项目时,字段似乎是颠倒的(TitleText)。对于所有示例项目(例如 News),Title 始终显示在顶部。

我知道有一个 ContainerName 属性可以设置为 tabname,但是我没有看到 Title 的任何属性覆盖或 News 类中的 Text,这怎么可能?

编辑新闻项

编辑新闻项目

编辑产品

编辑产品项目

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; }
    }
}

Working on N2 CMS I'm adding my own content type Product. I derive my Product class from ContentPageBase and I can add it in the content tree. When I edit an item however, the fields seem to be inverted (Title and Text). For all example items (e.g. News) Title always shows up at the top.

I understand there is a ContainerName property which can be set to a tabname, however I don't see any property overrides for Title or Text in the News class, so how can this be?

Editing news item

Editing news item

Editing product

Editing product item

Product.cs (custom)

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 (default)

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; }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南七夏 2024-10-28 10:09:46

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

请参阅类上的 WithEditableTitleWithEditableName 属性。

News 类不必指定它们,因为它继承自 ContentPageBase,而不是 Product 类正在使用的根 ContentItem 类。 ContentPageBase 已指定标题和名称编辑器,因此 News 无需再次指定。

The Title and Name editors aren't set on the properties themselves but on the Class.

See the WithEditableTitle and WithEditableName attributes on your class.

And News class doesn't have to specify them because it inherits from ContentPageBase instead of the root ContentItem class that your Product class is using. ContentPageBase has the Title and Name editors already specified so News doesn't have to again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文