- 我们在
ecshop
模板制作当中,有时候对广告的调用不能局限于默认的ecshop
的表情规则,比如要调用后台指定广告位下所有广告循环,如何处理呢? - 最模板抽空做了个函数:
function
get_position_ads
($id
)- {
- $
sql
= “select
*from
” . $GLOBALS
[‘ecs
’]->table
(‘ad
’) . ”where
position_id
= “.$id
.”AND
enabled
= 1order
by
ad_id
”; - $
rows
= $GLOBALS
[‘db
’]->getAll
($sql
); -
if
($rows
) - {
- $
sql
= “select
ad_width
,ad_height
from
” . $GLOBALS
[‘ecs
’]->table
(‘ad_position
’) . ”where
position_id
= “.$id
.”limit
1″; - $
ad_position
= $GLOBALS
[‘db
’]->getRow
($sql
); - {
- $
row
[‘pic
’]= ‘data
/afficheimg
/’.$row
[‘ad_code
’]; - $
row
[‘width
’] = $ad_position
[‘ad_width
’]; - $
row
[‘height
’] = $ad_position
[‘ad_height
’]; - }
- }
-
return
$rows
; - }
- 然后显示页加入 $
smarty
->assign
(‘zuimoban
’,get_position_ads
(1)); 后面的 1 指的是广告位ID
. - 模板里引入:
- {
foreach
from
=$zuimoban
item
=zuimobanlist
} - {/
foreach
} - 至此模板上调用指定广告位就正常显示了。 以后只需改指定广位下广告就行
转载请注明:汇站网 » ecshop
调用后台指定广告位下所有广告循环