ecshop教程

ECSHOP实现不同文章分类下的文章详情页使用不同的详情页模板

ecshop教程 51源码 2022-11-21 人阅读

ECSHOP实现不同文章分类下的文章详情页使用不同的详情页模板

使用ECSHOP系统做网站时,文章系统功能比较单一,很多时候,我们希望能有多种文章详情模板,

比如,使用文章来实现,公司简介,联系我们等,新闻文章内容等,这些详情内容模板是不一样的,可能需要3种、4种或者更多的不同模板。

一流资源网参考了不同商品详情不同模板的方法 修改后实现了

方法如下:

打开网站根目录下的 article.php文件,找到以下代码:

if(isset($article) && $article['cat_id'] > 2){    $smarty->display('article.dwt'$cache_id);}else{    $smarty->display('article_pro.dwt'$cache_id);}


修改为以下代码:

switch ($article['cat_id']){case 8:  $smarty->display('article8.dwt',      $cache_id);  breakcase 9:  $smarty->display('article9.dwt',      $cache_id);  breakcase 2:  $smarty->display('article_pro.dwt',      $cache_id);  breakdefault:  $smarty->display('article.dwt',      $cache_id);  break}


解释:

文章分类ID为2的文章详一屁股使用 article_pro.dwt模板,(这条是ECSHOP系统默认的模板,所以仍然给加上。)

文章分类ID为8的文章详一屁股使用 article8.dwt模板,

文章分类ID为9的文章详一屁股使用 article9.dwt模板,

未指定的其它文章分类下的文章详情全部使用 article.dwt模板,如果还需要指定其它分类下的单独模板,也可以加入一条代码即可:


case 9:  $smarty->display('article9.dwt',      $cache_id);  break;



版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/ecshop/684.html
文章来源: