在我的index/index
操作中,我正在调用我创建的表单类,并在index.phtml
视图中输出表单
<?php
echo $this->form;
但是当我查看页面源代码时,我得到的只是表单标记。我没有获得任何HTML HEAD BODY
标记来使其成为有效的标记页面。如何将这些添加到我的所有页面?
我有layouts/scripts/layout.phtml
但我不确定使用它的正确方法是什么。
答案 0 :(得分:3)
听起来你没有启用布局。
这样做的典型方法是通过configs/application.ini file:
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.layout.layout = "layout"
文件application/layouts/scripts/layout.phtml
应该包含模板的html代码,通常采用(如@Alkexander的答案中所述)视图助手headLink()
,headScript()
等。< / p>
答案 1 :(得分:1)
使用通用布局。在这个布局中,借助View Helpers创建doctype,head ...
$this->getHead('jquery');
$this->headLink()->appendStylesheet('/styles/common.css');
echo $this->headTitle();
echo $this->headMeta();
echo $this->headScript();
echo $this->headLink();
echo $this->headStyle();