Example #1
0
        public static IList<MenuItem> CreateMainNav(this IPublishedContent currentContent)
        {
            var items = new List<MenuItem>();
            var homeNode = currentContent.AncestorOrSelf(1);
            var umbracoConextProvider = DependencyResolver.Current.GetService<IUmbracoConextProvider>();
            var umbracoHelper = new UmbracoHelper(umbracoConextProvider.GetUmbracoContext());

            //Home Page

            //items.Add(new MenuItem
            //{
            //    Id = homeNode.Id,
            //    IsActive = homeNode.Id == currentContent.Id,
            //    Name = homeNode.Name,
            //    NodeTypeAlias = homeNode.DocumentTypeAlias,
            //    Url = homeNode.Url,
            //    SortOrder = homeNode.SortOrder,
            //    Content=homeNode,
            //    IsVisible = homeNode.IsVisible()
            //});

            items.AddRange(GetMenuItmes(homeNode, currentContent, 2, umbracoHelper));

            return items;
        }
Example #2
0
        public static IList<FooterItem> CreateFooterItems(this IPublishedContent currentContent)
        {
            var items = new List<FooterItem>();
            var homeNode = currentContent.AncestorOrSelf(1);
            homeNode.Children.ForEach(node => items.Add(new FooterItem
            {
                Id = node.Id,
                IsVisible = node.IsVisible(),
                Name = node.Name,
                NodeTypeAlias = node.DocumentTypeAlias,
                SortOrder = node.SortOrder,
                Url = node.Url,
                Children = GetChildrenFooterItems(node,2)
            }));

            return items;
        }
		public static IPublishedContent AncestorOrSelf(this IPublishedContent content, string nodeTypeAlias)
		{
			return content.AncestorOrSelf(node => node.DocumentTypeAlias == nodeTypeAlias);
		}
		public static IPublishedContent AncestorOrSelf(this IPublishedContent content, int level)
		{
			return content.AncestorOrSelf(node => node.Level == level);
		}
		public static IPublishedContent AncestorOrSelf(this IPublishedContent content)
		{
			//TODO: Why is this query like this??
			return content.AncestorOrSelf(node => node.Level == 1);
		}
        /// <summary>
        /// Returns relative to root element url
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static string RelativeUrl(this IPublishedContent node)
        {
            var rootNode = node.AncestorOrSelf();
            var rootReplaceUrl = "/";

            //check if root node is included in url
            var rootUrl = rootNode.Url;
            var pattern = String.Format("/{0}/$", rootNode.UrlName);
            if (Regex.IsMatch(rootUrl, pattern))
            {
                rootReplaceUrl = "/" + rootNode.UrlName + "/";
            }

            return node.Url.Replace(rootNode.Url, rootReplaceUrl);
        }
Example #7
0
 public static IPublishedContent GetRootNode(this IPublishedContent currentNode)
 {
     return currentNode.AncestorOrSelf(1);
 }
 public static IPublishedContent SecondLevelNode(this IPublishedContent node)
 {
     return node.AncestorOrSelf(2);
 }
 public static IPublishedContent RootNode(this IPublishedContent node)
 {
     return node.AncestorOrSelf(1);
 }
        /// <summary>
        /// Return the node where default settings are stored.
        /// </summary>
        public static IPublishedContent TopPage(this IPublishedContent content)
        {
            var topPage = (IPublishedContent)System.Web.HttpContext.Current.Items["TopPage"];

            if (topPage == null)
            {
                topPage = content.AncestorOrSelf(1);
                System.Web.HttpContext.Current.Items["TopPage"] = topPage;
            }

            return topPage;
        }
Example #11
0
 public static string AllDescentandsXPathFromRootNode(this IPublishedContent content,
     params string[] childNodeTypes)
 {
     return AllDescentandsXPath(content.AncestorOrSelf(1), childNodeTypes);
 }
Example #12
0
 /// <summary>
 ///  Проверяет существует ли на сайте узел node; учитывается региональная принадлежность узла (если не задана, то в некоторых случаях дочерних узлов),
 ///  существование документа для перенаправления (если задан) и его региональная принадлежность
 /// </summary>
 /// <param name="node">Проверяемый узел</param>
 /// <param name="host">Request.Url.Host</param>
 /// <returns></returns>
 public static bool Exists(this IPublishedContent node, string host)
 {
     if (node != null)
     {
         var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
         if (node.AncestorOrSelf("pubFederalMainPage") != null)
         {
             return !node.HasValue("umbracoRedirect") ||
                    umbracoHelper.TypedContent(node.GetPropertyValue<int>("umbracoRedirect"))
                        .IfNotNull(x => x.Exists(host));
         }
         var regions = node.GetRelatedNodes("regions");
         if (!regions.Any())
         {
             return node.HasValue("umbracoRedirect")
                 ? umbracoHelper.TypedContent(node.GetPropertyValue<int>("umbracoRedirect")).Exists(host)
                 : (node.DocumentTypeAlias != "pubPagePacket" || node.Descendants("contentItem").Any(x => x != null && x.Exists(host)));
         }
         if (regions.Any(x => x.UrlName.ToLower() == GetCurrentDomain(host)))
         {
             return !node.HasValue("umbracoRedirect") ||
                    umbracoHelper.TypedContent(node.GetPropertyValue<int>("umbracoRedirect"))
                        .IfNotNull(x => x.Exists(host));
         }
     }
     return false;
 }