doupa2871 2015-03-01 16:18 采纳率: 100%
浏览 92
已采纳

在prestashop中为CMS页面创建新模板

I have several pages created under the Preferences -> CMS which are ok. Now I need to create some more pages that will have a different look, is there a way to add like a different template and use the same CMS interface to do it?. I was thinking of something like:

Step 1. Create new cms-2.tpl Step 2. Modify the database to add a new "template" field Step 3. Modify the back office to add an extra field to the CMS page to choose the template to be used with the CMS page

So far I have been reading about "Creating pages without CMS" like in this link: Custom page in Prestashop 1.6 without CMS or this other link: Create custom page in Prestashop 1.5.3, but none of them seem to be what i am looking for.

Thanks

  • 写回答

2条回答 默认 最新

  • douyun8674 2015-09-30 17:00
    关注

    This worked for Prestashop 16.0.14:

    Copy /controllers/front/CmsController.php to /override/controllers/front/CmsController.php and find the last method of the class, which is initContent().

    The last line is $this->setTemplate(_PS_THEME_DIR_.'cms.tpl');. Change it to:

    if(is_file(_PS_THEME_DIR_.'cms-'.$this->cms->id.'.tpl')){
        $this->setTemplate(_PS_THEME_DIR_.'cms-'.$this->cms->id.'.tpl');
    }
    else{
        $this->setTemplate(_PS_THEME_DIR_.'cms.tpl');
    }
    

    Then you need to delete the file /cache/class_index.php to force cache recreation.

    Then you can create files inside your theme folder like this: cms-2.tpl where 2 is the id from your CMS page (just duplicate cms.tpl and change filename). Make sure you keep your cms.tpl as a fallback to all other CMS pages.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。