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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?