在 N2 cms 中编辑项目时的现场放置?
在 N2 CMS 上工作时,我添加了自己的内容类型 Product
。我从 ContentPageBase
派生我的 Product 类,并且可以将其添加到内容树中。但是,当我编辑项目时,字段似乎是颠倒的(Title
和 Text
)。对于所有示例项目(例如 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 product
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标题和名称编辑器不是在属性本身上设置的,而是在类上设置的。
请参阅类上的
WithEditableTitle
和WithEditableName
属性。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
andWithEditableName
attributes on your class.And News class doesn't have to specify them because it inherits from
ContentPageBase
instead of the rootContentItem
class that yourProduct
class is using.ContentPageBase
has the Title and Name editors already specified soNews
doesn't have to again.