ecshop首页楼层下显示对应的品牌图标调用方法
时间:2023年06月02日
/来源:网络
/编辑:佚名
ecshop 首页楼层下显示对应的品牌图标
1.效果:
2:源码分析;
html :
复制代码
<!--{if $goods_cat.id eq 951}-->
<!--{foreach from=$brands951 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 950}-->
<!--{foreach from=$brands950 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 1325}-->
<!--{foreach from=$brands1325 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 688}-->
<!--{foreach from=$brands688 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 732}-->
<!--{foreach from=$brands732 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 1397}-->
<!--{foreach from=$brands1397 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
复制代码
php :
复制代码
//////////////////////////////////////////////////////////////
/**
* 获得某个分类下的品牌 列表
*
* @access public
* @param int $cat
* @return array
*/
function get_cat_brands($cat = 0, $app = 'category')
{
$children = ($cat > 0) ? ' AND ' . get_children($cat) : '';
$sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(g.goods_id) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag ".
"FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ".
$GLOBALS['ecs']->table('goods') . " AS g ".
"WHERE g.brand_id = b.brand_id $children " .
"GROUP BY b.brand_id ORDER BY b.sort_order ASC, tag DESC limit 12 ";
$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;
}
调用:
$smarty->assign('brands951', get_cat_brands(951));
$smarty->assign('brands950', get_cat_brands(950));
$smarty->assign('brands1325', get_cat_brands(1325));
$smarty->assign('brands688', get_cat_brands(688));
$smarty->assign('brands732', get_cat_brands(732));
$smarty->assign('brands1397', get_cat_brands(1397));
1.效果:
2:源码分析;
html :
复制代码
<!--{if $goods_cat.id eq 951}-->
<!--{foreach from=$brands951 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 950}-->
<!--{foreach from=$brands950 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 1325}-->
<!--{foreach from=$brands1325 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 688}-->
<!--{foreach from=$brands688 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 732}-->
<!--{foreach from=$brands732 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
<!--{if $goods_cat.id eq 1397}-->
<!--{foreach from=$brands1397 item=brandCat}-->
<a href="{$brandCat.url}" target="_blank"><img src="data/brandlogo/{$brandCat.brand_logo}" width="102" height="50" style="margin:5px;" /></a>
<!--{/foreach}-->
<!-- {/if}-->
复制代码
php :
复制代码
//////////////////////////////////////////////////////////////
/**
* 获得某个分类下的品牌 列表
*
* @access public
* @param int $cat
* @return array
*/
function get_cat_brands($cat = 0, $app = 'category')
{
$children = ($cat > 0) ? ' AND ' . get_children($cat) : '';
$sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, COUNT(g.goods_id) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag ".
"FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ".
$GLOBALS['ecs']->table('goods') . " AS g ".
"WHERE g.brand_id = b.brand_id $children " .
"GROUP BY b.brand_id ORDER BY b.sort_order ASC, tag DESC limit 12 ";
$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;
}
调用:
$smarty->assign('brands951', get_cat_brands(951));
$smarty->assign('brands950', get_cat_brands(950));
$smarty->assign('brands1325', get_cat_brands(1325));
$smarty->assign('brands688', get_cat_brands(688));
$smarty->assign('brands732', get_cat_brands(732));
$smarty->assign('brands1397', get_cat_brands(1397));
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法