0

N2 CMS での作業 独自のコンテンツ タイプを追加していますProduct。Product クラスを派生させ、ContentPageBaseそれをコンテンツ ツリーに追加できます。ただし、アイテムを編集すると、フィールドが反転しているように見えます (TitleおよびText)。すべての例のアイテム (例: News)Titleは常に上部に表示されます。

tabnameContainerNameに設定できるプロパティがあることは理解していますが、クラスのプロパティのオーバーライドが表示されないので、どうすればよいでしょうか?TitleTextNews

ニュース記事の編集

ニュース記事の編集

商品の編集

商品アイテムの編集

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

1 に答える 1

2

タイトルエディタと名前エディタは、プロパティ自体ではなく、クラスに設定されます。

クラスの属性WithEditableTitleと属性を参照してください。WithEditableName

ContentPageBaseまた、Newsクラスは、クラスが使用しているルートContentItemクラスではなく、から継承するため、それらを指定する必要はありませんProductContentPageBaseタイトルエディタと名前エディタがすでに指定されているのでNews、再度指定する必要はありません。

于 2011-03-11T15:36:44.860 に答える