663 users online

Changing location of breadcrumb (nopCommerce 2.20)

Posted: 6 months ago Quote
Hi,

If anyone can shed some light on the following for me that would be great as I am still getting to grips with MVC after years of ASP.NET web forms development.

I am wanting to move the location of the breadcrumb trail so that it appears directly below the top level menu and isnt part of the column pages. I figured the best way to do this was to create a new widget but for the life of me cannot work out how to reference the catalog and product data so that I can parse the breadcrumb as the current site does, the following code is what I found for how the category page displays its breadcrumb.


@*category breadcrumb*@
@if (Model.DisplayCategoryBreadcrumb)
{
    <div class="breadcrumb">
        <a href="@Url.RouteUrl("HomePage")">@T("Categories.Breadcrumb.Top")</a> /
        @for (int i = 0; i < Model.CategoryBreadcrumb.Count; i++)
        {
            var catBr = Model.CategoryBreadcrumb[i];
            <a href="@Url.RouteUrl("Category", new { categoryId = catBr.Id, SeName = catBr.SeName })">@catBr.Name</a>
                                                                                                 if (i != Model.CategoryBreadcrumb.Count - 1)
                                                                                                 {
                <text>/</text>
                                                                                                 }
        }
        <br />
    </div>
    <div class="clear">
    </div>
}


I tried to copy this code into the widget but just can't work out how to reference the functionality above from the widget.
Alternatively, if anyone has managed to do what I am trying to do via a different method it would be fantastic to hear from.

Graham
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 6 months ago Quote
Are you looking for something like this , just have a look at my test website(http://www.teamlemon.co.uk)
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 6 months ago Quote
Hi,

Yes that is pretty much exactly the type of functionality I am looking to create, any help you can give me would be much appreciated or at the least if you can point me in the right direction.

Cheers,

Graham
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 6 months ago Quote
gcarr wrote:
Hi,

Yes that is pretty much exactly the type of functionality I am looking to create, any help you can give me would be much appreciated or at the least if you can point me in the right direction.

Cheers,

Graham


Well the solution is not elegant as it should be but it works though. I created a separate view for products breadcrumb and a hardcoded breadcrumb for homepage. For that I removed the integrated breadcrumb from the category view. Created 3 master pages : _Root.cshtml( To be used for Homepage) , _RootPages.cshtml(To be used by categories/products page) and
_RootTopicPages (To be used by contact us, login about us pages etc)

In the _Root.cshtml . I just hardcode the breadcrumb in HeaderMenu like:
<div class="nave">
  @Html.Action("Menu", "Common")

</div>
<div class="HpBreadcrumb">You are here: <a href="@Url.RouteUrl("HomePage")" >Home </a></div>

And for
_RootPages.cshtml

I added :
<div class="master-wrapper-content">
        
            @Html.Partial("Header")
            @Html.Partial("HeaderMenu")
            @Html.Partial("Breadcrumb")
            @Html.Action("WidgetsByZone", "Widget", new { widgetZone = Nop.Core.Domain.Cms.WidgetZone.BeforeContent })
            @RenderBody()
            @Html.Action("WidgetsByZone", "Widget", new { widgetZone = Nop.Core.Domain.Cms.WidgetZone.AfterContent })
            <div class="clear">
            </div>

Breadcrumb.cshtml:

@model CategoryModel
@using Nop.Web.Models.Catalog;
    @*category breadcrumb*@
    @if (Model.DisplayCategoryBreadcrumb)
    {
        <div class="breadcrumb">
            <a href="@Url.RouteUrl("HomePage")">@T("Categories.Breadcrumb.Top")</a> >>
            @for (int i = 0; i < Model.CategoryBreadcrumb.Count; i++)
            {
                var catBr = Model.CategoryBreadcrumb[i];
                <a href="@Url.RouteUrl("Category", new { categoryId = catBr.Id, SeName = catBr.SeName })">@catBr.Name</a>
                if (i != Model.CategoryBreadcrumb.Count - 1)
                {
                    <text>/</text>
                }
            }
            <br />
        </div>
        <div class="clear">
        </div>
    }

I didnt need breadcrumb for topic pages , thats why i didnt modify it .

Hope it makes sense
This post/answer is useful
2
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 6 months ago Quote
Cool, I needed that too! Thanks!
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 3 months ago Quote
Hi;

I starting today with nopCommerce and this explanation has been So useful!

My doubt is: From which files I have to call the three different cshtml to make them work correctly?

I hope you can help me!
Silvia
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Posted: 3 months ago Quote
pandita wrote:
Hi;

I starting today with nopCommerce and this explanation has been So useful!

My doubt is: From which files I have to call the three different cshtml to make them work correctly?

I hope you can help me!
Silvia


You can call different layouts by calling it in ColumnOne, three or the one which you have created , Layouts can be found under Nop.Web>Views>Shared, just changed the layout something like:
@{
    Layout = "~/Views/Shared/_RootTopicpage.cshtml";
}
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)