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 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?