zHaytam / SmartBreadcrumbs

A utility library for ASP.NET Core (both MVC and Razor Pages) websites to easily add and customize breadcrumbs.
https://blog.zhaytam.com/2018/06/24/asp-net-core-using-smartbreadcrumbs/
MIT License
161 stars 77 forks source link

How to remove index entry from generated breadcrumbs? #85

Closed midasw closed 3 years ago

midasw commented 3 years ago

Hello

Instead of having the index or home entry to show up in front of all breadcrumbs, I would like to have the option to disable it.

For example, I have an area called Manage, with an EmployeesController, of which the resulting breadcrumb would look like this:

Home / Manage / Employees / Action name

While I would like to just have:

Manage / Employees / Action name

Is this possible?

midasw commented 3 years ago

I've been able to achieve the desired behavior by disabling DefaultBreadcrumb, setting DontLookForDefaultNode to true as follows:

services.AddBreadcrumbs(GetType().Assembly, options =>
{
    options.TagName = "nav";
    options.TagClasses = "";
    options.OlClasses = "breadcrumb";
    options.LiClasses = "breadcrumb-item";
    options.ActiveLiClasses = "breadcrumb-item active";
    // Disable default node:
    options.DontLookForDefaultNode = true;
});
zHaytam commented 3 years ago

Hello,

That's exactly how it should be done. Feel free to close the issue if you don't have any other questions.

riverahugo commented 3 years ago

SmartBreadcrumbsException: FuncionariosController doesn't contain a valid action named Index. I have this problem with my action of my controller. I don't want to use Index action for default. I use, options.DontLookForDefaultNode = true; and doesn't work. I need help, and I using net core 2.1