有两个类,NodeBase和ContentSectionNode继承自抽象类NodeBase,我想知道是否有任何方法可以避免在ContentSectionNode构造函数中重复一段代码,同时也委托给基类构造函数.
抽象的NodeBase类ctors看起来像这样:
protected NodeBase(string tagType, string content)
: this()
{
TagType = tagType;
Content = content;
}
protected NodeBase(Guid? parentId, int? internalParentId, string tagType, string content)
: this(tagType, content)
{
ParentId = parentId;
InternalParentId = internalParentId;
}
Run Code Online (Sandbox Code Playgroud)
ContentSectionNode类ctors看起来像这样:
public ContentSectionNode(Guid createdBy)
: this()
{
_createdBy = createdBy;
_createdAt = DateTime.Now;
UpdatedAt = _createdAt;
UpdatedBy = _createdBy;
}
public ContentSectionNode(Guid createdBy, string tagType, string content)
:base(tagType, content)
{
_createdBy = createdBy;
_createdAt = DateTime.Now;
UpdatedAt = _createdAt;
UpdatedBy = _createdBy;
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试为某些文章标题创建类似行为的永久链接,我不想为永久链接添加新的数据库字段.所以我决定写一个帮助器来转换我的文章标题:
" O"focoasă"a pornit cruciada,împotrivabărbaţilorzgârciţi "to" o-focoasa-a-pornit-cruciada-impotriva-barbatilor-zgarciti ".
虽然我想出了如何用连字符替换空格并删除其他特殊字符(除了 - )使用:
title.gsub(/\s/, "-").gsub(/[^\w-]/, '').downcase
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何其他方法可以从一个.gsub方法调用替换一个特定的其他字符的字符,所以我不必为所有的链接title.gsub("ă","a")方法我本地化的UTF-8特殊字符.
我正在考虑用所有特殊字符和它们的对应物构建一个哈希,但我还没有弄清楚如何使用regexp的变量.
我在寻找的是:
title.gsub(/\s/, "-").gsub(*replace character goes here*).gsub(/[^\w-]/, '').downcase
Run Code Online (Sandbox Code Playgroud)
谢谢!
我很难在Sitecore 7中构建过滤系统.
我在页面的同一级别有2个子布局.
子布局A是一个侧边栏,其中包含一个复选框列表,并且具有使用所选值填充列表的事件.子布局B显示一组项目.
我想做的是,将填充的列表从子布局A发送到子布局B,以便根据用户选择的内容过滤项目列表.我能够通过Session传递数据来做到这一点,但这不是处理数据的最佳方式.
我已经尝试为子布局A定义一个属性并在那里加载列表,但是我无法从子布局B获得子布局A的确切实例以便读取填充的属性.此外,尝试Page.FindControl("IdOfSomeElementFromSublayoutA")始终在Sublayout B中返回null.尽管我已将Page转换为包含Sublayouts的.aspx页面.
我正在使用Sitecore 7 Update 2.
非常感谢你的时间.