把这个函数插入到index.php中最下面即可,
function get_index_ad(){
$sql = 'SELECT ad_type, content,ad_name,url FROM ' . $GLOBALS['ecs']->table("ad_custom") ;
$res = $GLOBALS['db']->getAll($sql);
$ads = array();
foreach ($res AS $adx => $row)
{
$ads[$adx]['ad_type'] = $row['ad_type'];
$ads[$adx]['content'] = $row['content'];
$ads[$adx]['url'] = $row['url'];
$ads[$adx]['ad_name'] = $row['ad_name'];
}
return $ads;
}
然后在
那一堆smarty中定义一个标签即可(不过到时候后台添加图片是在首页主广告那里自定义添加)
$smarty->assign('index_adlist', get_index_ad());
然后在DWT文件中引用即可
如:<!--{foreach from=$index_adlist item=ads}-->
<li><a target="_blank" href="{$ads.url}"><img src="{$ads.content}" alt="{$ads.ad_name}"></a></li>
<!--{/foreach}-->
循环来自标签'index_adlist' 其中url为图片链接地址 content为图片 ad_name为图片名称