A5下载 - 努力做内容最丰富最安全的下载站!

A5站长下载站

当前位置:A5下载 > 源码技巧 > Ecshop > 实现ecshop不同的分类调用不同的模版

实现ecshop不同的分类调用不同的模版

时间:2015-08-03 09:18作者:fang人气:79

目的:ecshop不同的分类调用不同的模版,如果没有就调用默认的模版

方法:模仿分类样式,COPY一个分类模版

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

实现ecshop不同的分类调用不同的模版

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.自己制作一份新的模版,在后台输入到需要自义的分类里就可以。

 

标签实现,ecshop,不同,分类,调用,模版,目的,ecsho

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

公众号