ecshop自定义品牌显示

文章描述:

ecshop品牌页面默认是没有商品不显示的,如何自定义全部显示呢?

1、打开brand.php在最下面新增以下代码:

function get_brand_all($cat = 0,$app = 'brand'){
    $sql = "SELECT brand_id, brand_name, brand_logo ,brand_desc".
        " FROM " . $GLOBALS['ecs']->table('brand') .
        " WHERE  is_show = 1 " .
        "ORDER BY brand_id DESC LIMIT 0,28";
    $row = $GLOBALS['db']->getAll($sql);

    foreach ($row AS $key => $val)
    {
        $row[$key]['url'] = build_uri($app, array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']);
    }

    return $row;
}

 

2、在brand.php里面54行新增以下代码:

$smarty->assign('brand_now_all',get_brand_all());

3、模板循环

<!-- {foreach from=$brand_now_all name="brand_list_foreach" item=brand_data} -->
  <div class="brandBox">
   <h4><span>{$brand_data.brand_name}</span>({$brand_data.goods_num})</h4>
   <!-- {if $brand_data.brand_logo} -->
     <div class="brandLogo">
      <a href="{$brand_data.url}"><img src="data/brandlogo/{$brand_data.brand_logo}" alt="{$brand_data.brand_name|escape:html} ({$brand_data.goods_num})" /></a>
      </div>
   <!-- {/if} -->
    <p title="{$brand_data.brand_desc}">{$brand_data.brand_desc}</p>
   </div>
<!-- {/foreach} -->

 

发布时间:2021/07/07

发表评论