Hi can you look at here if this solves your issues? https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/common-web-page-component-tutorials/how-to-create-a-breadcrumb-in-episerver/
If not then let me know I can help you with the custom one.
Daniel,
Im not sure I fully understand your question, can you elaborate on: "How can I show the correct breadcrumb?"
From your example your product1 exists in the categories category1.1, category1.2 and category1.3.
What breadcrumb end result are you trying to achieve?
currently the list of products goes with this url.
https://yoursite/category1.1/category1.1.2/
but when I access the product it looks like this:
https://yoursite/product
therefore I cannot get the breadcrumb from the url since the query is from bakend and it always returns the configured main one and not the navigation one.
What would be the solution so that the breadcrumb is correct from the product list navigation?
without skipping the default breadcrumb configured in the
episerver/Commerce/Catalog
Routing context aware links in Commerce catalog | Optimizely Deve
this could be helpful
I'm sure it's a good solution.
I have tried to do it without success.
- in the catalog when I enter a product
breadcrumb never matches "Additional Categories"
- and when I browse the web the same thing happens.
breadcrumbs never contain Additional Categories
On the other hand I have a web component called Breadcrumbs
public ActionResult Index(IContent currentContent)
{
var model = new BreadcrumbsViewModel
{
Breadcrumbs = LoadBreadcrumbs(currentContent).ToArray(),
};
return PartialView(model);
}
private IEnumerable<BreadcrumbItem> LoadBreadcrumbs(IContent currentContent)
{
var breadcrumbs = currentContent is PageData page
? LoadPageBreadcrumbs(page)
: _breadcrumbsService.LoadCommerceBreadcrumbs(currentContent);
return breadcrumbs;
}
private IEnumerable<BreadcrumbItem> LoadPageBreadcrumbs(PageData pageData)
{
var breadcrumbItems = Enumerable.Empty<BreadcrumbItem>();
if (ShowBreadcrumbsForPage(pageData))
{
var breadcrumbsContent =
new[] { _contentLoader.GetStartPage(_contentVersionRepository) }
.Concat(GetAncestors(pageData).TakeWhile(x => !(x is StartPage)).Reverse())
.Concat(new[] { pageData })
.Select(x => new NamedLink(x.Name, Url.ContentUrl(x.ContentLink)));
var tempLeaf = TempData.GetBreadcrumbLeaf();
if (tempLeaf != null)
{
breadcrumbsContent = breadcrumbsContent.Concat(new[] { tempLeaf });
}
breadcrumbItems = _breadcrumbsService.LoadBreadcrumbItems(breadcrumbsContent);
}
return breadcrumbItems;
}
but it always returns the breadcumb set as main for the article
I think maybe you were along the right lines with storing information in the session in that case.
Maybe you could have a variable that stores the last visited category page? Then when you navigate to the product page, you should double check that the stored category does indeed contain the product (so doesn't matter if its primary or additional) then navigate back up the category tree from the stored category.
I have a .net 4.6.1 project with cms and commerce in cms I have the page structure. in commerce I have the catalog tree view example catalog commerce: home -> category1.1 -> category1.2 -> product1 home -> category1.1 -> category1.3 -> product1 When I access product1 in commerce in belongs to. main category home -> category1.1 -> viewall Additional Categories home -> category1.1 -> category1.3 home -> category1.1 -> category1.2 When I enter the product page I always get the full breadcrumb because it is the main one. but the user was able to browse home -> category1.1 -> category1.3 How can I show the correct breadcrumb?