0

我正在使用最新版本的 EE2 和一个名为 Exp:resso store 的插件。

我将产品分配到一个类别,并且在大多数情况下,所有这些都运行良好。下面是我的代码:

<div class="col-md-7">
    {exp:channel:categories channel="products" style="linear"}
    <section class="section accordion repeater">
        <h3>
            {category_name}
            <div class="icon">
                <img src="/assets/local/img/plus-icon.jpg" alt="">
            </div>
        </h3>
        <div class="accordion-content">
            {exp:store:search orderby="title" sort="asc" category="{category_id}"}
                {exp:store:product entry_id="{entry_id}"}
                <p class="accordion-download">
                    <a href="#">{title} - {price}</a>
                    <span><a href="#"><img src="/assets/local/img/add-to-cart.jpg" alt="">Add to cart</a></span>
                </p>
                {/exp:store:product}                
            {/exp:store:search}                     
        </div>
    </section>
    {/exp:channel:categories}
</div>

No products exist如果类别中没有任何内容,我正在尝试找到一种显示消息的方法。我尝试使用{count}, {total_results}&{total_rows}来检查是否没有任何产品。问题是我尝试的一切显然都是错误的,因为没有任何输出:/

提前致谢

4

1 回答 1

1

商店搜索标签是频道条目标签对的包装器,因此您需要使用{if no_results}标签对。

<div class="col-md-7">
    {exp:channel:categories channel="products" style="linear"}
    <section class="section accordion repeater">
        <h3>
            {category_name}
            <div class="icon">
                <img src="/assets/local/img/plus-icon.jpg" alt="">
            </div>
        </h3>
        <div class="accordion-content">
            {exp:store:search orderby="title" sort="asc" category="{category_id}"}
                {exp:store:product entry_id="{entry_id}"}
                <p class="accordion-download">
                    <a href="#">{title} - {price}</a>
                    <span><a href="#"><img src="/assets/local/img/add-to-cart.jpg" alt="">Add to cart</a></span>
                </p>
                {/exp:store:product}
                {if no_results}
                  There are no products
                {/if}
            {/exp:store:search}                     
        </div>
    </section>
    {/exp:channel:categories}
</div>

如果您没有创建用于将产品添加到购物车的表单,还应该提到您可以使用该{store_field_short_name:price}变量来减少页面上的查询数量。大多数商店的东西,如 sku、重量、测量值都可以通过使用字段短名称后跟:variable

于 2015-12-23T19:40:21.397 回答