加法块标题来分隔在主页上Nopcommerce产品 [英] Adding block titles to separate products on homepage Nopcommerce

查看:190
本文介绍了加法块标题来分隔在主页上Nopcommerce产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加块标题的一些产品在主页上分开,

我使用nopcommerce 3.0源代码,

当期我有24个产品在主页上,

我要显示22,然后插入一个标题栏,

则标题旗帜下显示的最后两个产品

在code我能找到的是:

HomepageProducts.cshtml视图

  @model的IList< ProductOverviewModel>@using Nop.Web.Models.Catalog;@if(Model.Count大于0)
{
    < D​​IV CLASS =产品网主页进行产品网>
        < D​​IV CLASS =标题>
            <强> @T(HomePage.Products)< / STRONG>
        < / DIV>
        @foreach(以型号VAR项)
        {
            < D​​IV CLASS =项盒>
                @ Html.Partial(_ ProductBox项)
            < / DIV>
        }
    < / DIV>
}

更新

我现在已经修改了code与@Razor给出了一个答案,

现在显示的第一个22个产品,然后我的标题,但之后并没有显示剩余产品,

  @if(Model.Count大于0)
    {
        < D​​IV CLASS =产品网主页进行产品网>
            < D​​IV CLASS =标题>
                <强> @T(HomePage.Products)< / STRONG>
            < / DIV>           @ {
            INT I = 0;
            的foreach(在型号VAR项)
            {
                如果(我!= 22)
                {
                    < D​​IV CLASS =项盒>
                    @ Html.Partial(_ ProductBox项)
                    < / DIV>
                    i ++;
                }
             }            < D​​IV CLASS =项盒>
                我的块标题句!
            < / DIV>            的foreach(在型号VAR项)
            {
                如果(I GT; 22)
                {
                    < D​​IV CLASS =项盒>
                    @ Html.Partial(_ ProductBox项)
                    < / DIV>
                }
            }
           }        < / DIV>
    }


解决方案

这样的事情应该工作。

 < D​​IV CLASS =产品网主页进行产品网>
    < D​​IV CLASS =标题>
        <强> @T(HomePage.Products)< / STRONG>
    < / DIV>
    @for(VAR I = 0; I< Model.Count();我++)
    {
        VAR项目=模型[I]        < D​​IV CLASS =项盒>
            @ Html.Partial(_ ProductBox项)
        < / DIV>        如果(我== 22)
        {
            < D​​IV CLASS =大旗>广告与LT; / DIV>
        }
    }
< / DIV>

i want to add block titles to separate some products on the homepage,

i am using nopcommerce 3.0 source,

as current i have 24 products on the homepage,

i wish to show 22 and then insert a title banner,

then under the title banner show the final two products

the code i can find is:

HomepageProducts.cshtml view

@model IList<ProductOverviewModel>

@using Nop.Web.Models.Catalog;

@if (Model.Count > 0)
{
    <div class="product-grid home-page-product-grid">
        <div class="title">
            <strong>@T("HomePage.Products")</strong>
        </div>
        @foreach (var item in Model)
        {
            <div class="item-box">
                @Html.Partial("_ProductBox", item)
            </div>
        }
    </div>
}

UPDATE

I have now amended the code with an answer provided by @Razor,

it now displays the first 22 products and then my title but does not display the remaining products after,

@if (Model.Count > 0) 
    {
        <div class="product-grid home-page-product-grid">
            <div class="title">
                <strong>@T("HomePage.Products")</strong>
            </div>

           @{
            int I = 0;
            foreach (var item in Model)
            {
                if(I != 22)
                {
                    <div class="item-box">
                    @Html.Partial("_ProductBox", item)
                    </div>
                    I++;
                }
             }

            <div class="item-box">
                My block title sentence!
            </div>

            foreach(var item in Model)
            {
                if(I > 22)
                {
                    <div class="item-box">
                    @Html.Partial("_ProductBox", item)
                    </div>
                }
            }
           }

        </div>
    }

解决方案

Something like this should work.

<div class="product-grid home-page-product-grid">
    <div class="title">
        <strong>@T("HomePage.Products")</strong>
    </div>
    @for (var i = 0; i < Model.Count(); i++)
    {
        var item = Model[i];

        <div class="item-box">
            @Html.Partial("_ProductBox", item)
        </div>

        if (i == 22)
        {
            <div class="banner">banner</div>
        }
    }
</div>

这篇关于加法块标题来分隔在主页上Nopcommerce产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆