ecshop英文字母查询品牌

文章描述:

ecshop根据英文字母查询数据并且分配到模板中进行渲染

1、在brand.php新增下面代码

function get_brand_en($en,$cat = 0,$app = 'brand'){
    $sql = "SELECT brand_id, brand_name, brand_logo ".
        "FROM " . $GLOBALS['ecs']->table('brand') .
        " WHERE  en_zm = '$en'  AND 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、分配变量

$smarty->assign('goods_all_a',get_brand_en($en='A'));

 

3、模板循环

href:{$brand_data_a.url} name:{$brand_data_a.brand_name}

 

发布时间:2022/10/12

发表评论