public static string MenuTitle(XPathNodeIterator ni) { Node node = UmbracoUtil.GetNode(ni); if (node != null) { return(UmbracoUtil.GetMenuTitle(node)); } return(string.Empty); }
public static XPathNodeIterator GetDescendantsViaXPath(XPathNodeIterator from, string xpath) { Node node = UmbracoUtil.GetNode(from); if (node != null) { XPathNavigator navigator = node.ToXPathNavigator(); return(navigator.Select(xpath)); } return(CreateEmptyIterator()); }
/// <summary> /// Get a link tag with overload for the link text and a css class to add to the a tag. /// </summary> /// <remarks> /// Gets a link tag where the href points to the node and you can add a css class /// </remarks> /// <param name="nodeId">The node id.</param> /// <param name="linkText">The link text.</param> /// <param name="cssClass">Css class</param> /// <returns>An a tag</returns> /// <example> /// <code lang="xsl" title=""> /// <![CDATA[ /// <xsl:value-of select="upac:GetLinkTag(1541, 'Hi World', 'highlight')" /> /// Would give: <a href="/Subjectpage/HelloWorld" class="highlight">Hi World</a> /// ]]> /// </code> /// <code lang="xsl" title="With empty link text"> /// <![CDATA[ /// <xsl:value-of select="upac:GetLinkTag(1541, '', 'highlight')" /> /// Would give: <a href="/Subjectpage/HelloWorld" class="highlight">Hello World</a> /// ]]> /// </code> /// <code lang="xsl" title="With empty link text and css class"> /// <![CDATA[ /// <xsl:value-of select="upac:GetLinkTag(1541, '', '')" /> /// Would give: <a href="/Subjectpage/HelloWorld">Hello World</a> /// ]]> /// </code> /// </example> public static string GetLinkTag(string nodeId, string linkText, string cssClass) { Node node = UmbracoUtil.GetNode(nodeId); if (node != null) { string text = !string.IsNullOrEmpty(linkText) ? linkText : UmbracoUtil.GetMenuTitle(node); string url = LinkManager.GetNodeUrl(node); string linkClass = string.IsNullOrEmpty(cssClass) ? string.Empty : string.Format(" class=\"{0}\"", cssClass); if (text != string.Empty && url != string.Empty) { string tag = string.Format("<a href=\"{0}\"{1}>{2}</a>", url, linkClass, text); return(tag); } } return(string.Empty); }