Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding block titles to separate products on homepage Nopcommerce
    primarykey
    data
    text
    <p>i want to add block titles to separate some products on the homepage,</p> <p>i am using nopcommerce 3.0 source,</p> <p>as current i have 24 products on the homepage,</p> <p>i wish to show 22 and then insert a title banner, </p> <p>then under the title banner show the final two products</p> <p>the code i can find is:</p> <p><strong>HomepageProducts.cshtml view</strong></p> <pre><code>@model IList&lt;ProductOverviewModel&gt; @using Nop.Web.Models.Catalog; @if (Model.Count &gt; 0) { &lt;div class="product-grid home-page-product-grid"&gt; &lt;div class="title"&gt; &lt;strong&gt;@T("HomePage.Products")&lt;/strong&gt; &lt;/div&gt; @foreach (var item in Model) { &lt;div class="item-box"&gt; @Html.Partial("_ProductBox", item) &lt;/div&gt; } &lt;/div&gt; } </code></pre> <p><strong>UPDATE</strong></p> <p>I have now amended the code with an answer provided by @Razor,</p> <p>it now displays the first 22 products and then my title but does not display the remaining products after,</p> <pre><code>@if (Model.Count &gt; 0) { &lt;div class="product-grid home-page-product-grid"&gt; &lt;div class="title"&gt; &lt;strong&gt;@T("HomePage.Products")&lt;/strong&gt; &lt;/div&gt; @{ int I = 0; foreach (var item in Model) { if(I != 22) { &lt;div class="item-box"&gt; @Html.Partial("_ProductBox", item) &lt;/div&gt; I++; } } &lt;div class="item-box"&gt; My block title sentence! &lt;/div&gt; foreach(var item in Model) { if(I &gt; 22) { &lt;div class="item-box"&gt; @Html.Partial("_ProductBox", item) &lt;/div&gt; } } } &lt;/div&gt; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload