本文整理汇总了C#中IPublishedContent.AncestorOrSelf方法的典型用法代码示例。如果您正苦于以下问题:C# IPublishedContent.AncestorOrSelf方法的具体用法?C# IPublishedContent.AncestorOrSelf怎么用?C# IPublishedContent.AncestorOrSelf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPublishedContent
的用法示例。
在下文中一共展示了IPublishedContent.AncestorOrSelf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GlobalModel
public GlobalModel(IPublishedContent content)
{
var rootNode = content.AncestorOrSelf(1);
CompanyName = rootNode.GetPropertyValue<string>("companyName");
CompanyAddress = rootNode.GetPropertyValue<string>("companyAddress");
CompanyPhone = rootNode.GetPropertyValue<string>("companyPhone");
CompanyEmail = rootNode.GetPropertyValue<string>("companyEmail");
}
示例2: Map
public static IntranetMaster Map(IPublishedContent content, IntranetMaster model)
{
// Reference to the root (frontpage) node
IPublishedContent rootNode = content.AncestorOrSelf(1);
//Reference to the level 2 node
IPublishedContent level2Node = content.AncestorOrSelf(2);
// Get main navigation
//model.MainNavigation = NavigationMapper.GetMainNavigation(rootNode, content);
// Get top navigation
//model.TopNavigation = NavigationMapper.GetTopNavigation(rootNode, content);
model.LeftNavigation = NavigationMapper.GetIntranetMainNavigation(level2Node, content);
model.MetaDescription = content.GetProperty("metaDescription") != null
? content.GetPropertyValue<string>("metaDescription")
: string.Empty;
model.MetaKeywords = content.GetProperty("metaKeywords") != null
? content.GetPropertyValue<string>("metaKeywords")
: string.Empty;
model.RedirectUrl = content.GetProperty("redirectURL") != null
? content.GetPropertyValue<string>("redirectURL")
: string.Empty;
model.BodyCssClass = level2Node != null
? level2Node.GetPropertyValue<string>("cssClassName")
: string.Empty;
model.SiteName = rootNode.GetProperty("siteName") != null
? rootNode.GetPropertyValue<string>("siteName")
: string.Empty;
model.SiteDescription = rootNode.GetProperty("siteDescription") != null
? rootNode.GetPropertyValue<string>("siteDescription")
: string.Empty;
model.Name = content.Name;
return model;
}
示例3: GetFromContent
//public Footer Footer { get; private set; }
public static Settings GetFromContent(IPublishedContent content, Settings model)
{
IPublishedContent root = content.AncestorOrSelf(1);
model.Email = root.GetPropertyValue<string>("email");
model.Mobile = root.GetPropertyValue<string>("mobile");
model.Sitename = root.GetPropertyValue<string>("sitename");
//model.Footer = Footer.GetFromContent(content, new Footer());
return model;
}
示例4: Map
public static IEnumerable<MenuItem> Map(IPublishedContent currentPage, bool sideNav = false)
{
List<MenuItem> menuItemList = new List<MenuItem>();
MenuItem frontPage = new MenuItem();
var siteRoot = currentPage.AncestorOrSelf(1);
if (!siteRoot.GetPropertyValue<bool>("umbracoNaviHide"))
{
frontPage.Name = siteRoot.Name;
frontPage.Url = siteRoot.Url;
menuItemList.Add(frontPage);
}
foreach (var child in siteRoot.Children.Where(x => x.GetPropertyValue<bool>("showInTopMenu") == sideNav && x.GetPropertyValue<bool>("umbracoNaviHide") == false))
{
MenuItem menuItem = new MenuItem();
menuItem.Name = child.Name;
if (child.IsDocumentType("Link"))
{
menuItem.OpenInNewWindow = child.GetPropertyValue<bool>("targetNewWindow");
menuItem.Url = child.GetPropertyValue<string>("linkUrl");
}
else
{
menuItem.Url = child.Url;
}
menuItemList.Add(menuItem);
}
if (menuItemList.Any())
{
return menuItemList;
}
return null;
}
示例5: IsHomepageOf
public static bool IsHomepageOf(IPublishedContent homepage, IPublishedContent someNode)
{
var someNodesHomepage = someNode.AncestorOrSelf("Homepage");
return someNodesHomepage.Id.Equals(homepage.Id);
}
示例6: GetFooterChildNodes
private List<IPublishedContent> GetFooterChildNodes(IPublishedContent node)
{
var homePage = node.AncestorOrSelf(1);
var footer = homePage.Children.FirstOrDefault(content => content.DocumentTypeAlias.Equals("Footer", StringComparison.OrdinalIgnoreCase));
if (footer == null)
return new List<IPublishedContent>();
return footer.Children.ToList();
}
示例7: BaseModel
public BaseModel(IPublishedContent content)
: base(content)
{
this.HomePage = content.AncestorOrSelf(1);
}
示例8: SinglePageOfType
public static IPublishedContent SinglePageOfType(this UmbracoHelper umbraco, IPublishedContent currentPage,
string nodeTypeAlias)
{
var home = currentPage.AncestorOrSelf(1);
var xpath = String.Format("//{0}[@id={1}]//{2}",home.DocumentTypeAlias, home.Id,nodeTypeAlias);
var node = umbraco.TypedContentSingleAtXPath(xpath);
return node;
}