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

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

星辰博客方法:模仿分类样式,COPY一个分类模版

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

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


1,在分类表ecs_category里增加一个字段,style_moban,属性就与style相同吧,
或者执行以下SQL语句 alter table  `ecs_category` add style_moban varchar(255) NOT NULL DEFAULT '';
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.自己制作一份新的模版,在后台输入到需要自义的分类里就可以。


转载于:https://my.oschina.net/u/779687/blog/143199

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值