Jon.Hopley.Net wrote:When trying to show Recently Added Products as a partial view in the home page (Index.chtml) I remove the layout code (ColumnsOne) from the view and add RecentlyAddedProducts to Index.cshtml yet the header loads into the page as well so that when you scroll to where New Products should be the nopcommerce logo appears. Has any body else encountered this, I'm not sure why. Maybe im missing something? I can not see why the layout continues to load.
Hi, This post can be useful for nopCommerce Community
We can show new products on Home page very easily, Need simple modify only view (cshtml file) part.
For this task at first open new product view file : ~/Themes/ThemeName/Views/Product/NewProducts.cshtml
Replace this code :
@model IList<ProductOverviewModel>
@{
var controllerName = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
var actionName = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
if (controllerName == "Home" && actionName == "Index")
{
Layout = "";
}
else
{
Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
//title
Html.AddTitleParts(T("PageTitle.NewProducts").Text);
}
}
@using Nop.Web.Models.Catalog;
<div class="page recently-added-products-page">
<div class="page-title">
<a href="@Url.RouteUrl("NewProductsRSS")" class="link-rss" title="@T("Products.NewProducts.RSS.Hint")">@T("Products.NewProducts.RSS")</a>
<h1>@T("Products.NewProducts")</h1>
</div>
<div class="page-body">
@if (Model.Count > 0)
{
<div class="product-grid">
<div class="item-grid">
@foreach (var product in Model)
{
<div class="item-box">
@Html.Partial("_ProductBox", product)
</div>
}
</div>
</div>
}
</div>
</div>
Then add (call) this action on Home page view file : ~/Themes/ThemeName/Views/Home/Index.cshtml
@Html.Action("NewProducts", "Product")
Note : I applied this Technic on nopCommerce 3.7 version