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?
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
{
}
}
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; }
}
}
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.