ecshop二次开发的简单实例


PHP #ecshop #二次开发2012-05-02 09:57
要进行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}–>
完成!

相关文章

粤ICP备11097351号-1