Esempio n. 1
0
 public BreadcrumbBuilder(Breadcrumbs breadcrumbs)
 {
     this.breadcrumbs = breadcrumbs;
 }
Esempio n. 2
0
        public static IHtmlString Breadcrumbs(this HtmlHelper helper, Action<BreadcrumbBuilder> action)
        {
            IRequestContext context = helper.ViewData["Context"] as IRequestContext;

             Breadcrumbs b = new Breadcrumbs();

             action(new BreadcrumbBuilder(b));

             // Render
             StringBuilder html = new StringBuilder();

             foreach (BreadcrumbNode node in b.Items)
             {
            if (node.IsHome)
               html.Append("<li class=\"home\">");
            else if (node.IsCurrent)
               html.Append("<li class=\"nohover\">");
            else
               html.Append("<li>");

            // if the node don't have the href specified
            if (node.IsHome)
            {
               html.AppendFormat("<a class=\"home drop\" href=\"{0}\">", node.Href);
               html.Append(node.Text);
               html.Append("</a>");

               // if I have a siteid in the request (we are in the context of a Site specific view)
               // then I can show the site menu as a megadropdown of the "home" breadcrumb node.
               //if (helper.ViewContext.RequestContext.RouteData.Values.ContainsKey("siteid"))
               if (context != null && context.ManagedSite != null)
               {
                  //int siteId = Convert.ToInt32(helper.ViewContext.RequestContext.RouteData.Values["siteid"]);
                  html.Append(GetSiteMegaMenu(helper, context.ManagedSite));
               }

            }
            else if (node.IsCurrent)
            {
               html.AppendFormat("<span><strong>{0}</strong></span>", node.Text);
            }
            else
            {
               html.AppendFormat("<a href=\"{0}\">{1}</a>", node.Href, node.Text);
            }

            html.Append("</li>");

            if (!node.IsCurrent)
               html.Append("<li class=\"nohover separator\">&nbsp;</li>");

             }

             return helper.Raw(html.ToString());
        }