Beispiel #1
0
        public ActionResult Rendering()
        {
            BreadcrumbWrapper breadcrumbs = new BreadcrumbWrapper();
            IList <Item>      items       = GetBreadcrumbItems();

            foreach (Item item in items)
            {
                if (!IsTemplateBlacklisted(item.TemplateName))
                {
                    BreadcrumbViewModel crumb = new BreadcrumbViewModel(item);
                    crumb.BreadcrumbName = item["Name"];
                    crumb.IsActive       = Sitecore.Context.Item.ID == item.ID;
                    crumb.BreadcrumbUrl  = LinkManager.GetItemUrl(item);
                    breadcrumbs.SitecoreBreadcrumbs.Add(crumb);
                }
            }

            Product product = SiteContext.Current.CatalogContext.CurrentProduct;

            Category lastCategory = SiteContext.Current.CatalogContext.CurrentCategory;

            foreach (var category in SiteContext.Current.CatalogContext.CurrentCategories)
            {
                BreadcrumbViewModelUcommerce crumb = new BreadcrumbViewModelUcommerce()
                {
                    BreadcrumbNameUcommerce = category.DisplayName(),
                    BreadcrumbUrlUcommerce  = CatalogLibrary.GetNiceUrlForCategory(category)
                };
                lastCategory = category;
                breadcrumbs.UcommerceBreadcrumbs.Add(crumb);
            }

            if (product != null)
            {
                var breadcrumb = new BreadcrumbViewModelUcommerce()
                {
                    BreadcrumbNameUcommerce = product.DisplayName(),
                    BreadcrumbUrlUcommerce  = CatalogLibrary.GetNiceUrlForProduct(product, lastCategory)
                };
                breadcrumbs.UcommerceBreadcrumbs.Add(breadcrumb);
            }

            if (IsTemplateWhitelisted(Sitecore.Context.Item.TemplateName))
            {
                BreadcrumbViewModelUcommerce currentCrumb = new BreadcrumbViewModelUcommerce();
                currentCrumb.BreadcrumbNameUcommerce = Sitecore.Context.Item.DisplayName;
                currentCrumb.BreadcrumbUrlUcommerce  = LinkManager.GetItemUrl(Sitecore.Context.Item);
                breadcrumbs.UcommerceBreadcrumbs.Add(currentCrumb);
            }


            return(View(breadcrumbs));
        }
        public ActionResult Rendering()
        {
            BreadcrumbWrapper breadcrumbs = new BreadcrumbWrapper();
            IList <Item>      items       = GetBreadcrumbItems();

            foreach (Item item in items)
            {
                if (!IsTemplateBlacklisted(item.TemplateName))
                {
                    BreadcrumbViewModel crumb = new BreadcrumbViewModel(item);
                    crumb.BreadcrumbName = item["Name"];
                    crumb.IsActive       = Sitecore.Context.Item.ID == item.ID;
                    crumb.BreadcrumbUrl  = LinkManager.GetItemUrl(item);
                    breadcrumbs.SitecoreBreadcrumbs.Add(crumb);
                }
            }

            var product = _catalogContext.CurrentProduct;

            var lastCategory = _catalogContext.CurrentCategory;

            foreach (var category in _catalogContext.CurrentCategories)
            {
                BreadcrumbViewModelUcommerce crumb = new BreadcrumbViewModelUcommerce
                {
                    BreadcrumbNameUcommerce = category.DisplayName,
                    BreadcrumbUrlUcommerce  = _urlService.GetUrl(_catalogContext.CurrentCatalog, new [] { category }.Compact().ToArray())
                };
                lastCategory = category;
                breadcrumbs.UcommerceBreadcrumbs.Add(crumb);
            }

            if (product != null)
            {
                var breadcrumb = new BreadcrumbViewModelUcommerce
                {
                    BreadcrumbNameUcommerce = product.DisplayName,
                    BreadcrumbUrlUcommerce  = _urlService.GetUrl(_catalogContext.CurrentCatalog, new [] { lastCategory }.Compact().ToArray(), product)
                };
                breadcrumbs.UcommerceBreadcrumbs.Add(breadcrumb);
            }

            if (IsTemplateWhitelisted(Sitecore.Context.Item.TemplateName))
            {
                BreadcrumbViewModelUcommerce currentCrumb = new BreadcrumbViewModelUcommerce();
                currentCrumb.BreadcrumbNameUcommerce = Sitecore.Context.Item.DisplayName;
                currentCrumb.BreadcrumbUrlUcommerce  = LinkManager.GetItemUrl(Sitecore.Context.Item);
                breadcrumbs.UcommerceBreadcrumbs.Add(currentCrumb);
            }


            return(View(breadcrumbs));
        }