要进行ecshop二次开发,得熟悉ecshop的模板架构及目录情况,哪些地方需要修改,下面列举一个简单的ecshop二次开发实例,并讲解实现的方法与步骤,供大家参考,如有不正请指教:
首先建文件名losever.com.php在根目录下代码如下:
<?php
define(‘IN_ECS’, true);
require(dirname(__FILE__) . ‘/includes/init.php’);
$smarty->assign(‘test_goods’,get_goods());
$smarty->display(‘losever.com.dwt’);
function get_goods()
{
$sql = ’select * FROM ‘ . $GLOBALS['ecs']->table(‘goods’) . ‘ ORDER BY goods_id desc limit 10′;
$arr = $GLOBALS['db']->getAll($sql);
for ($i = 0, $count = count($arr); $i < $count; $i++) { $arr[$i]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($arr[$i]['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $arr[$i]['goods_name'];
$arr[$i]['url'] = build_uri(‘goods’, array(‘gid’ => $arr[$i]['goods_id']), $arr[$i]['goods_name']);
$arr[$i]['thumb'] = get_image_path($arr[$i]['goods_id'], $arr[$i]['goods_thumb'],true);
$arr[$i]['price'] = price_format($arr[$i]['shop_price']);
}
return $arr;
}
?>再在模板目录(themes)下建losever.com.dwt,粘贴代码:
<!–{foreach from=$test_goods item=goods}–>
<a href=”{$goods.url}”><img class=”goodsimg” src=”{$goods.thumb}” alt=”{$goods.name|escape:html}” /></a>
<a title=”{$goods.name|escape:html}” href=”{$goods.url}”>{$goods.short_style_name}</a>
<!–{/foreach}–>
完成!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/39677.html