/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing) { // Do not process } else { if (PortalContext.ViewMode == ViewModeEnum.Edit || PortalContext.ViewMode == ViewModeEnum.Design) { return; } var delimiter = GetStringValue("Delimiter", ">"); bool includeKenticoNodes = ValidationHelper.GetBoolean(this.GetValue("IncludeKenticoNodes"), true); var breadcrumbs = new List <BreadcrumbViewModel>(); if (includeKenticoNodes) { var documentsOnPath = CurrentDocument.DocumentsOnPath; foreach (var node in documentsOnPath) { if (!node.NodeAlias.IsNullOrWhiteSpace() && PageTemplateInfoProvider.GetPageTemplateInfo(node.GetUsedPageTemplateId()).DisplayName != "Catalog" && PageTemplateInfoProvider.GetPageTemplateInfo(node.GetUsedPageTemplateId()).DisplayName != "Product") { breadcrumbs.Add( new BreadcrumbViewModel { BreadcrumbName = node.NodeAlias, BreadcrumbUrl = node.AbsoluteURL }); breadcrumbs.Add(new BreadcrumbViewModel { BreadcrumbName = delimiter }); } } } var delimiterBreadcrumb = new BreadcrumbViewModel { BreadcrumbName = delimiter }; Product product = SiteContext.Current.CatalogContext.CurrentProduct; Category lastCategory = SiteContext.Current.CatalogContext.CurrentCategory; var defaultCatalogDataProvider = ObjectFactory.Instance.Resolve <IDefaultCatalogDataProvider>(); if (lastCategory == null && CurrentDocument.NodeAlias == "Catalog") { lastCategory = defaultCatalogDataProvider.GetDefaultCategory(); SiteContext.Current.CatalogContext.CurrentCategories.Add(lastCategory); } if (lastCategory == null && product == null && CurrentDocument.NodeAlias == "Product") { product = defaultCatalogDataProvider.GetDefaultProduct(); } if (SiteContext.Current.CatalogContext.CurrentCategories.Any()) { foreach (var category in SiteContext.Current.CatalogContext.CurrentCategories) { var breadcrumb = new BreadcrumbViewModel { BreadcrumbName = category.DisplayName(), BreadcrumbUrl = CatalogLibrary.GetNiceUrlForCategory(category) }; lastCategory = category; breadcrumbs.Add(breadcrumb); if (category == SiteContext.Current.CatalogContext.CurrentCategory && product == null) { break; } breadcrumbs.Add(delimiterBreadcrumb); } } if (product != null) { var breadcrumb = new BreadcrumbViewModel { BreadcrumbName = product.DisplayName(), BreadcrumbUrl = CatalogLibrary.GetNiceUrlForProduct(product, lastCategory) }; breadcrumbs.Add(breadcrumb); } if (breadcrumbs.Any() && breadcrumbs.Last().BreadcrumbName == delimiter) { breadcrumbs.Remove(breadcrumbs.Last()); } Breadcrumbs.DataSource = breadcrumbs; Breadcrumbs.DataBind(); } }