分类分类
更新时间:2026-05-10 23:58:56作者:fang
目的:ecshop不同的分类调用不同的模版,如果没有就调用默认的模版
方法:模仿分类样式,COPY一个分类模版
注意:红色部分是新增加的,黑色部分,是让你找到位置,知道在哪里增加

1,在分类表ecs_category里增加一个字段,style_moban,属性就与style相同吧,
或者执行以下SQL语句 alter table `ecs_category` add style_moban varchar(255) NOT NULL DEFAULT '';
2,修改admintemplatescategory_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.修改admincategory.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.修改语言库
languageszh_cnadmincategory.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.自己制作一份新的模版,在后台输入到需要自义的分类里就可以。
相关
修真情缘角色扮演303.33 MBv1.0.02026-05-10
下载我的小独角兽女孩休闲益智380.89 MBv1.0.232026-05-10
下载超级种田男孩手机版经营养成1.31Gv1.0.92026-05-10
下载不必要的实验冒险游戏64.9 MBv1.1.592026-05-10
下载军师联盟策略游戏163.2 MBv0.0.12026-05-10
下载翻天喜地凑大钱手机版休闲益智138.72 MBv1.0.92026-05-10
下载东离剑游纪手游动作射击1.6Gv1.4.22026-05-10
下载天猫养车商家版App学习办公74.95 MBv0.6.12026-05-10
下载掌上命运方舟App手游辅助137.48 MBv1.9.12026-05-10
下载退役军人服务APP生活服务67.16 MBv1.2.52026-05-10
下载屯漫漫画APP资讯阅读23.06 MBv2.0.32026-05-10
下载蛋仔派对蛋壳App手游辅助185.73 MBv0.0.22026-05-10
下载









