Exclude top level from breadcrumb?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi All.

I have the following category structure:

Top Level
--Team1
-----Team1Products1
-----Team1Products2
-----Team1Products3
--Team2
-----Team2Products1
-----Team2Products2
-----Team2Products3



I have removed the menu as it is not necessary for my simple navigation, and am only using the breadcrumb as a Nav.

I want to exlude the top level menu from the breadcrumb, so that each team stays within it's own subcategory and can't navigate to other team's sites.

I expect that I need to edit the breadcrumb code in the Category template and the Product template (MyDomain/Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml and MyDomain/Views/Catalog/ProductTemplate.Simple.cshtml)


It seems like I should be able to modify the code here to ignore the topmost level menu, and dynamically build the breadcrumb:

       <div class="breadcrumb">
            Navigation: <a href="~/Team1">Team 1 Home</a>
      <ul>
        @foreach (var cat in Model.CategoryBreadcrumb)
                {
                    var isLastCategory = cat.Id == Model.Id;
                    <li>
                        @if (isLastCategory)
                        {
                            <strong class="current-item">@cat.Name</strong>
                        }
                        else
                        {
                            <a href="@Url.RouteUrl("Category", new {SeName = cat.SeName})" title="@cat.Name">@cat.Name</a>
                            <span class="delimiter">@breadcrumbDelimiter</span>
                        }
                    </li>
                }
            </ul>
        </div>


But it doesn't show anything except the "Navigation:  Team 1 Home"



Question 1: How can I improve the code to avoid Hardcoding the "Team 1 Home" in favor of something more dynamic (the name of the highest level Team 1 category would be fine)

Question 2: Why isn't the FOREACH loop working to generate a deeper breadcrumb?


Thanks for any help!
6 years ago
I believe I've got an acceptable solution.

1) I simply removed the code just before the FOREACH loop in both the Category and Product templates, and the HOME page link is gone -- perfect. But now nothing shows up... until...

2) I found the "Show Breadcrumb" in the Category Settings under Configuration with the ADVANCED option on.  This solved Question 2, and when the full breadcrumb appeared it was without the HOME Link in Question 1, so that's solved as well.

Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.