doulu4316 2013-10-16 19:13
浏览 16
已采纳

在CakePHP中加载页眉和页脚的更好方法是什么?

I am getting my foot wet with CakePHP and wondering what is better to load views. I tried searching but could not find satisfying answer for this small question. If I have to load header and footer along with content, what should be better approach :

1) Using $this->fetch("header") in view.ctp

or 2) I don't know how is it possible but, loading different views one after another from controller like we do in CodeIgniter ($this->load->view("header")).

  • 写回答

1条回答 默认 最新

  • doupapin172773 2013-10-16 19:31
    关注

    As mentioned by user2076809, you'll probably want to use elements for this purpose, to keep things DRY: book.cakephp.org/2.0/en/views.html#elements.

    Be aware though that Cake uses layouts (http://book.cakephp.org/2.0/en/views.html#layouts) to handle the header and footer by default, so take a look at app/View/Layouts/default.ctp and make sure you don't have redundant code there (for example, it has the <head> tag with all the default CSS includes).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失