ECSHOP如何实现不同的产品分类调用不同的模版

ecshop模板中心在和客户沟通过程中,有客户问到如何在不同的分类页面样式也不一样,关于这块的改动程序,让我们ECSHOP开发中心的技术小杨来说明一下。目的:不同的分类调用不同的模板,如果没有就调用默认的模板 方法:模仿分类样式,COPY一个分类模板

注意:红色部分是新增加的,黑色部分,是让你找到位置,知道在哪里增加

1,在分类表ecs_category里增加一个字段,style_moban,属性就与style相同吧,或者执行以下SQL语句 alter table `ecs_category` add style_moban varchar(255) NOTNULLDEFAULT ”;2,修改admin\templates\category_info.htm <tr> <td class="label"><a href="javascript:showNotice(‘noticeGoodsSN’);" title="{$lang.form_notice}"><img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.notice_style}"></a>{$lang.cat_style}:</td> <td> <input type="text" name="style" value="{$cat_info.style|escape}" size="40" /> <br /> <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="noticeGoodsSN">{$lang.notice_style}</span> </td> </tr> <tr> <td class="label"><a href="javascript:showNotice(‘noticeGoodsSN’);" title="{$lang.form_notice}"><img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.notice_style}"></a>{$lang.cat_style_moban}:</td> <td> <input type="text" name="style_moban" value="{$cat_info.style_moban|escape}" size="40" /> <br /> <span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="noticeGoodsSN">{$lang.notice_style_moban}</span> </td> </tr>

2.修改admin\category.php 第一处:$cat[‘style’] = !empty($_POST[‘style’]) ? trim($_POST[‘style’]) : ”; $cat[‘style_moban’] = !empty($_POST[‘style_moban’]) ? trim($_POST[‘style_moban’]) : ”;第二处:$cat[‘style’] = !empty($_POST[‘style’]) ? trim($_POST[‘style’]) : ”; $cat[‘style_moban’] = !empty($_POST[‘style_moban’]) ? trim($_POST[‘style_moban’]) : ”;3.修改语言库languages\zh_cn\admin\category.php第一处:$_LANG[‘cat_style’] = ‘分类的样式表文件’;$_LANG[‘cat_style_moban’] = ‘分类的模板文件’;第二处:$_LANG[‘notice_style’] = ‘您可以为每一个商品分类指定一个样式表文件。例如文件存放在 themes 目录下则输入:themes/style.css’;$_LANG[‘notice_style_moban’] = ‘您可以为每一个商品分类指定一个模板文件。例如文件存放在 themes 目录下则输入:themes/category.dwt’;到这里,在后台就可以输入分类模板了,接下来,是如何调用4.修改根目录下的:category.php找到行,$smarty->display(‘category.dwt’, $cache_id);(注意应该是第二处(2.71就只有一处),本文件 有两处,我的文件修改过了,所以也不懂是第几行,300-400之间的那一处)

替换成://获取自定义分类增加的信息$cat_id = intval($_REQUEST[‘id’]);$sql = "SELECT * FROM " .$GLOBALS[‘ecs’]->table(‘category’). " WHERE cat_id=’$cat_id’ LIMIT 1";$cat_info = $GLOBALS[‘db’]->getRow($sql);/*———————–新增加的自定议分类模板—————————– */$template_cat = $cat_info[‘style_moban’];if($template_cat !=”){$smarty->display($template_cat, $cache_id);}else{$smarty->display(‘category.dwt’, $cache_id);}

5.自己制作一份新的模板,在后台输入到需要自义的分类里就可以。

,明天的希望,让我们忘了今天的痛苦

ECSHOP如何实现不同的产品分类调用不同的模版

相关文章:

你感兴趣的文章:

标签云: