Where should partial templates files be placed in Phalcon? Is there any config for that?
Nik*_*los 12
谐音
他们必须在view文件夹下.示例结构如下:
views/
about/ <- AboutController
index/ <- IndexController
contact/ <- ContactController
layouts/ <- Templates to override or add to the current template process
partials/ <- (name can be anything) where you store your partials
Run Code Online (Sandbox Code Playgroud)
如果您希望您的partials位于特定的子文件夹中,那么您需要在partial参数中定义它
$this->partial('partials/header');
Run Code Online (Sandbox Code Playgroud)
以上将在views/partials文件夹中查找名称为header.phtml或者header.volt注册视图引擎的文件.(phtml是默认值).
注意您不限于使用文件夹添加部分内容.他们可以愉快地自己在views文件夹中.您可以按照自己views认为合适的方式整理文件夹.
下面的layouts文件夹views包含可以在应用程序流程中的任何位置使用但不是部分的模板.将它们视为当前模板流的插件.
main将在控制器层中调用称为模板的布局,如下所示:
$this->view->setTemplateAfter('main');
Run Code Online (Sandbox Code Playgroud)
如果你导航说/about/index,Phalcon会选择views\index.volt文件,然后是layouts\main.volt最后的views\about\index.volt
注意再次我使用上面的伏特示例 - 它可以很容易地是phtml或您使用的任何其他View引擎(默认为phtml).
HTH
| 归档时间: |
|
| 查看次数: |
5212 次 |
| 最近记录: |