private void LoadTrailForCategory(BreadCrumbViewModel model, CategorySnapshot cat, bool linkAll)
        {
            if (cat == null) return;
            if (cat.Hidden) return;

            List<CategorySnapshot> allCats = MTApp.CatalogServices.Categories.FindAllPaged(1, int.MaxValue);

            List<CategorySnapshot> trail = new List<CategorySnapshot>();
            trail = Category.BuildTrailToRoot(cat.Bvin, MTApp.CurrentRequestContext);

            if (trail == null) return;

            // Walk list backwards
            for (int j = trail.Count - 1; j >= 0; j += -1)
            {
                if (j != 0 || linkAll == true)
                {
                    model.Items.Enqueue(AddCategoryLink(trail[j]));
                }
                else
                {
                    model.Items.Enqueue(new BreadCrumbItem() { Name = trail[j].Name });
                }
            }
        }
Example #2
0
        public string Render(MerchantTribeApplication app, BreadCrumbViewModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div class=\"breadcrumbs\">");
            sb.Append("<div class=\"links\">");
            if (model.HideHomeLink == false)
            {
                sb.Append("<a href=\"" + app.StoreUrl(false, false) + "\">Home</a>" + model.Spacer);
            }           
            while (model.Items.Count > 0)
            {
                var item = model.Items.Dequeue();
                if (item.Link == string.Empty)
                {
                    sb.Append("<span class=\"current\">" + HttpUtility.HtmlEncode(item.Name) + "</span>");
                }
                else
                {
                    sb.Append("<a href=\"" + item.Link + "\" title=\"" + HttpUtility.HtmlEncode(item.Title) + "\">" + HttpUtility.HtmlEncode(item.Name) + "</a>");
                }
                        
                if (model.Items.Count > 0 && model.Items.Peek() != null)
                {
                    sb.Append(model.Spacer);
                }
            }
            sb.Append("</div>");
            sb.Append("</div>");

            return sb.ToString();
        }
 public ActionResult ManualTrail(List<BreadCrumbItem> extras)
 {
     BreadCrumbViewModel model = new BreadCrumbViewModel();
     model.HomeName = MerchantTribe.Commerce.Content.SiteTerms.GetTerm(MerchantTribe.Commerce.Content.SiteTermIds.Home);
     if (extras != null)
     {
         foreach (BreadCrumbItem item in extras)
         {
             model.Items.Enqueue(item);
         }
     }
     return View("BreadCrumb", model);
 }
        public ActionResult CategoryTrail(Category cat, List<BreadCrumbItem> extras)
        {
            CategorySnapshot snap = new CategorySnapshot(cat);

            BreadCrumbViewModel model = new BreadCrumbViewModel();
            model.HomeName = MerchantTribe.Commerce.Content.SiteTerms.GetTerm(MerchantTribe.Commerce.Content.SiteTermIds.Home);

            LoadTrailForCategory(model, snap, false);

            if (extras != null)
            {
                foreach (BreadCrumbItem item in extras)
                {
                    model.Items.Enqueue(item);
                }
            }
            return View("BreadCrumb", model);
        }
        // Get: /Policies/Faq
        public ActionResult Faq()
        {
            // Breadcrumbs
            BreadCrumbViewModel crumbs = new BreadCrumbViewModel();
            crumbs.HomeName = SiteTerms.GetTerm(SiteTermIds.Home);
            crumbs.Items.Enqueue(new BreadCrumbItem()
            {
                Name = SiteTerms.GetTerm(SiteTermIds.CustomerService),
                Link = Url.Content("~/ContactUs")
            });
            crumbs.Items.Enqueue(new BreadCrumbItem() { Name = SiteTerms.GetTerm(SiteTermIds.FAQ) });
            ViewBag.BreadCrumbTrail = crumbs;

            // Titles
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.FAQ);

            Policy p = MTApp.ContentServices.Policies.FindOrCreateByType(PolicyType.Faq);
            if (p == null) p = new Policy();
            return View(p);
        }
        private BreadCrumbViewModel BuildBreadCrumbs(string path)
        {
            BreadCrumbViewModel result = new BreadCrumbViewModel();
            result.HideHomeLink = true;

            List<BreadCrumbItem> items = new List<BreadCrumbItem>();

            string workingPath = path.TrimEnd('\\');

            bool finished = false;
            while (finished == false)
            {
                workingPath = workingPath.TrimEnd('\\');
                if (workingPath.Length < 1)
                {
                    finished = true;
                    break;
                }                
                string dir = System.IO.Path.GetFileName(workingPath);

                items.Add(new BreadCrumbItem()
                {
                    Link = Url.Content("~/bvadmin/content/filemanager?path=" + workingPath),
                    Name = dir,
                    Title = dir
                });
                workingPath = System.IO.Path.GetDirectoryName(workingPath);
            }
            items.Add(new BreadCrumbItem()
            {
                Link = Url.Content("~/bvadmin/content/filemanager"),
                Name = "Root",
                Title = "Root"
            });

            for (int i = items.Count - 1; i >= 0; i--)
            {
                result.Items.Enqueue(items[i]);
            }
            return result;
        }
        // Get: /Policies/Faq
        public ActionResult Faq()
        {
            // Breadcrumbs
            BreadCrumbViewModel crumbs = new BreadCrumbViewModel();
            crumbs.HomeName = SiteTerms.GetTerm(SiteTermIds.Home);
            crumbs.Items.Enqueue(new BreadCrumbItem()
            {
                Name = SiteTerms.GetTerm(SiteTermIds.CustomerService),
                Link = Url.Content("~/ContactUs")
            });
            crumbs.Items.Enqueue(new BreadCrumbItem() { Name = SiteTerms.GetTerm(SiteTermIds.FAQ) });            
            var breadRender = new code.TemplateEngine.TagHandlers.BreadCrumbs();
            ViewBag.BreadCrumbsFinal = breadRender.Render(MTApp, crumbs);

            // Titles
            ViewBag.Title = SiteTerms.GetTerm(SiteTermIds.FAQ);

            Policy p = MTApp.ContentServices.Policies.FindOrCreateByType(PolicyType.Faq);
            if (p == null) p = new Policy();
            return View(p);
        }
Example #8
0
        public string RenderCategory(MerchantTribeApplication app, List<BreadCrumbItem> extras, Category cat)
        {            
            CategorySnapshot snap = new CategorySnapshot(cat);

            BreadCrumbViewModel model = new BreadCrumbViewModel();
            model.HomeName = MerchantTribe.Commerce.Content.SiteTerms.GetTerm(MerchantTribe.Commerce.Content.SiteTermIds.Home);

            LoadTrailForCategory(model, snap, false, app);

            if (extras != null && extras.Count > 0)
            {
                foreach (BreadCrumbItem item in extras)
                {
                    model.Items.Enqueue(item);
                }
            }

            return Render(app, model);
        }
Example #9
0
 private void LoadTrailForProduct(BreadCrumbViewModel model, Product p, MerchantTribeApplication app)
 {
     if (p == null) return;
     CategorySnapshot currentCategory = null;
     List<CategorySnapshot> cats = app.CatalogServices.FindCategoriesForProduct(p.Bvin);
     if ((cats.Count > 0))
     {
         currentCategory = cats[0];
     }
     LoadTrailForCategory(model, currentCategory, true, app);
     model.Items.Enqueue(new BreadCrumbItem() { Name = p.ProductName });
 }
Example #10
0
        public string RenderProduct(MerchantTribeApplication app, List<BreadCrumbItem> extras, Product product)
        {            
            BreadCrumbViewModel model = new BreadCrumbViewModel();
            model.HomeName = MerchantTribe.Commerce.Content.SiteTerms.GetTerm(MerchantTribe.Commerce.Content.SiteTermIds.Home);

            LoadTrailForProduct(model, product, app);

            if (extras != null)
            {
                foreach (BreadCrumbItem item in extras)
                {
                    model.Items.Enqueue(item);
                }
            }
            return Render(app, model);
        }