コード例 #1
0
        /// <summary>
        /// 生成帮助中心面包屑
        /// </summary>
        /// <param name="helper">HtmlHelper</param>
        /// <param name="viewContext">当前视图上下文</param>
        /// <returns></returns>
        public static IHtmlString CreateBreadCrumb(this HtmlHelper helper, ViewContext viewContext)
        {
            var data          = viewContext.RouteData;
            var id            = data.Values["id"] ?? "0";
            var mainCatalogId = Convert.ToInt32(id);
            var catalog       = CatalogCacheManager.FindById(mainCatalogId);

            /*
             * <ul class="list-unstyled breadcrumb">
             *     <li><a href="~/help/index">帮助中心</a></li>
             *     <li><a href="~/help/index">开始使用</a></li>
             *     <li>通道申请</li>
             * </ul>
             */
            var sb = new StringBuilder();

            sb.AppendFormat("<ul class='list-unstyled breadcrumb'>");
            sb.AppendFormat("<li><a href='/help/index'>帮助中心</a></li>");
            var hasChild = catalog.ParentID > 0;

            if (!hasChild)
            {
                sb.AppendFormat("<li>{0}</li>", catalog.ClassName);
            }
            else
            {
                var parent = CatalogCacheManager.FindById(catalog.ParentID);
                sb.AppendFormat("<li><a href='/help/catalog/{0}'>{1}</a></li>", parent.ID, parent.ClassName);
                sb.AppendFormat("<li>{0}</li>", catalog.ClassName);
            }
            sb.AppendFormat("</ul>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
コード例 #2
0
        /// <summary>
        /// 生成帮助中心面包屑
        /// </summary>
        /// <param name="helper">HtmlHelper</param>
        /// <param name="catalogId">当前分类ID</param>
        /// <returns></returns>
        public static IHtmlString CreateDetailBreadCrumb(this HtmlHelper helper, int catalogId)
        {
            var catalog = CatalogCacheManager.FindById(catalogId);

            /*
             * <ul class="list-unstyled breadcrumb">
             *     <li><a href="~/help/index">帮助中心</a></li>
             *     <li><a href="~/help/index">开始使用</a></li>
             *     <li>通道申请</li>
             * </ul>
             */
            if (catalog == null)
            {
                return(MvcHtmlString.Create(""));
            }
            var sb = new StringBuilder();

            sb.AppendFormat("<ul class='list-unstyled breadcrumb'>");
            sb.AppendFormat("<li><a href='/help/index'>帮助中心</a></li>");
            var hasChild = catalog.ParentID > 0;

            if (!hasChild)
            {
                sb.AppendFormat("<li>{0}</li>", catalog.ClassName);
            }
            else
            {
                var parent = CatalogCacheManager.FindById(catalog.ParentID);
                sb.AppendFormat("<li><a href='/help/catalog/{0}'>{1}</a></li>", parent.ID, parent.ClassName);
                sb.AppendFormat("<li>{0}</li>", catalog.ClassName);
            }
            sb.AppendFormat("</ul>");
            return(MvcHtmlString.Create(sb.ToString()));
        }
コード例 #3
0
        /// <summary>
        /// 生成帮助中心左侧菜单
        /// </summary>
        /// <param name="helper">HtmlHelper</param>
        /// <param name="viewContext">当前视图上下文</param>
        /// <returns></returns>
        public static IHtmlString CreateHelpMenu(this HtmlHelper helper, ViewContext viewContext)
        {
            var data          = viewContext.RouteData;
            var id            = data.Values["id"] ?? "0";
            var mainCatalogId = Convert.ToInt32(id);
            var cat           = CatalogCacheManager.FindById(mainCatalogId);
            var isRoot        = cat.ParentID == 0;

            if (!isRoot)
            {
                mainCatalogId = CatalogCacheManager.FindById(cat.ParentID).ID;
            }
            var parents = CatalogCacheManager.FindAllEnabledRoots();
            var sb      = new StringBuilder();

            sb.AppendFormat("<ul class='list-unstyled'>");
            parents.ForEach(x =>
            {
                sb.AppendFormat("<li>");
                sb.AppendFormat("<a{0} href='/help/catalog/{1}'>{2}</a>", x.ID == mainCatalogId ? " class='active'" : "", x.ID, x.ClassName);
                sb.AppendFormat("</li>");
            });
            sb.AppendFormat("</ul>");
            return(MvcHtmlString.Create(sb.ToString()));
        }