Пример #1
0
        private static SelectListItemTree CreateItem(SiteNode siteNode, RequestContext requestContext)
        {
            if (siteNode == null)
            {
                return new SelectListItemTree();
            }

            var selectListItem = new SelectListItemTree();

            var site = Kooboo.CMS.Sites.Models.IPersistableExtensions.AsActual(siteNode.Site);
            selectListItem.Text = string.IsNullOrEmpty(site.DisplayName) ? site.Name : site.DisplayName;
            selectListItem.Value = site.FullName;

            string parent = requestContext.GetRequestValue("parent");

            selectListItem.Selected = site.FullName.EqualsOrNullEmpty(parent, StringComparison.CurrentCultureIgnoreCase);

            var children = siteNode.Children;
            var items = new List<SelectListItemTree>();
            foreach (var c in children)
            {
                items.Add(CreateItem(c, requestContext));
            }
            selectListItem.Items = items;
            return selectListItem;
        }
Пример #2
0
        private static void CreateItem(SiteNode siteNode, RequestContext requestContext, List<SelectListItem> list)
        {
            var selectListItem = new SelectListItem();
            list.Add(selectListItem);
            if (siteNode != null)
            {
                var site = (siteNode.Site).AsActual();
                selectListItem.Text = site.FriendlyName;
                selectListItem.Value = site.FullName;

                siteNode.Children.ForEach((node, index) =>
                {
                    CreateItem(node, requestContext, list);
                });
            }
        }