Add extra menu item and folder.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hello,

I am creating a theme for nopCommerce for my customer and have replaced the homepage in the theme (as the customer wanted a clean looking homepage).

Now I have a menu-item called 'New Products' which links to /newproducts subfolder and the appropriate page, but this only shows recently added items. I wanted to add to this menu a 'Shop' item pointing to /shop (which does not exist yet) like on the default homepage, where I can put the categories, etc...

The /shop should have the same layout as the default 'Home' page.

Can anyone help me how to make www.mysite.com/shop and to point it to a shop.cshtml page (and where I need to put this page?).

Thank you very much for any replies and help :-)
11 years ago
JurgenVDP wrote:
Can anyone help me how to make www.mysite.com/shop and to point it to a shop.cshtml page (and where I need to put this page?).


Hello

What will [ shop.cshtml ] have in it ? You already have pages that display all the products !

Thanks
11 years ago
Yes, the shop.cshtml will be an exact copy of the home.cshtml, let's say that the content of the page is less important. It is just that I don't know how to setup the www.site.com/shop link and point that to the correct .cshtml file :)
11 years ago
Hmm .. I take it you have good reasons for what you're wanting. :)

Go to [ Nop.Web > Infrastructure > RouteProvider.cs ] and add the following between all the listed routes:


routes.MapLocalizedRoute("Shop",
                            "shop/",
                            new { controller = "Catalog", action = "Shop" }, null);


Then in [ Nop.Web > Controllers > CatalogController.cshtml ] add the following:


public ActionResult Shop()
{
    return View();
}


Once you've done that, right click on [ Shop() ] and choose [ Add View ], leave the name as Shop.

Now to call it, you need a link format like so:

<li><a href="@Url.RouteUrl("Shop")">Shop</a></li>


That would give you a blank page (View) called Shop, to have interesting stuff in it, you would need to give it access to the relevant ViewModels (easy to do, just look at all relevant existing code for Homepage).

Hope that helps.
11 years ago
Ciwan,

Thanks for your help... I was not aware that I needed to change source code and recompile for this :-)

I thought it was just an option to change Menu.cshtml and add the reference for the new menu. I guess it is not possible to make a theme then with different menu's and links without changing the source code and recompiling.

I was using a binary only installation, without the source code. Took me a while to figure it out, but I think I got it working!

I really appreciate the feedback you gave to get my problem resolved.

Thank you!
11 years ago
In no source nop2.5 version, I do not see the files. Does that mean I cannot add /shop in the header-menu?
11 years ago
Hi,
I have another question!!!

When I tried to remove Information Block on the left Panel through ColumnsThree.cshtml, the body section is completely messed up.


This is the code I removed from the ColumnThree.cshtml.

@Html.Action("InfoBlock", "Common")
        <div class="clear">
        </div>
11 years ago
That suggests you've also accidently removed a closing or starting <div> somewhere. :)
10 years ago
Hi there..Can any1 upload the standard ColumnsThree.cshtml  for v2.80 messed mine up and keeps giving me a compilation error when trying to load up my site.. thx
10 years ago
The following is the ColumnsThree.cshtml view from 2.80 (https://hg01.codeplex.com/nopcommerce/file/78a0980489bd/src/Presentation/Nop.Web/Views/Shared/_ColumnsThree.cshtml):


@{
    Layout = "~/Views/Shared/_Root.cshtml";
}
@{
    //current category ID
    int currentCategoryId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("category", StringComparison.InvariantCultureIgnoreCase))
    {
        currentCategoryId = Convert.ToInt32(Url.RequestContext.RouteData.Values["categoryId"].ToString());
    }


    //current manufacturer ID
    int currentManufacturerId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("manufacturer", StringComparison.InvariantCultureIgnoreCase))
    {
        currentManufacturerId = Convert.ToInt32(Url.RequestContext.RouteData.Values["manufacturerId"].ToString());
    }


    //current product ID
    int currentProductId = 0;
    if (Url.RequestContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.InvariantCultureIgnoreCase) &&
        Url.RequestContext.RouteData.Values["action"].ToString().Equals("product", StringComparison.InvariantCultureIgnoreCase))
    {
        currentProductId = Convert.ToInt32(Url.RequestContext.RouteData.Values["productId"].ToString());
    }
}

<div class="leftside-3">
    @if (IsSectionDefined("left"))
    {
        @RenderSection("left")
    }
    else
    {
        @Html.Widget("left_side_column_before")
        <div class="clear">
        </div>
        @Html.Action("CategoryNavigation", "Catalog", new { currentCategoryId = currentCategoryId, currentProductId = currentProductId })
        <div class="clear">
        </div>
        @Html.Action("ManufacturerNavigation", "Catalog", new { currentManufacturerId = currentManufacturerId })
        <div class="clear">
        </div>
        @Html.Action("PopularProductTags", "Catalog")
        <div class="clear">
        </div>
        @Html.Action("PollBlock", "Poll", new { systemKeyword = "LeftColumnPoll" })
        <div class="clear">
        </div>
        @Html.Widget("left_side_column_after")
    }
</div>
<div class="center-3">
    @Html.Widget("main_column_before")
    @RenderBody()
    @Html.Widget("main_column_after")
</div>
<div class="rightside-3">
    @if (IsSectionDefined("right"))
    {
        @RenderSection("right")
    }
    else
    {
        @Html.Widget("right_side_column_before")
        <div class="clear">
        </div>
        @Html.Action("NewsletterBox", "Newsletter")
        <div class="clear">
        </div>
        @Html.Action("RecentlyViewedProductsBlock", "Catalog")        
        <div class="clear">
        </div>  
        @Html.Action("InfoBlock", "Common")  
        <div class="clear">
        </div>  
        @Html.Action("PollBlock", "Poll", new { systemKeyword = "RightColumnPoll" })
        <div class="clear">
        </div>
        @Html.Widget("right_side_column_after")
    }
</div>
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.