【发布时间】:2015-09-01 13:12:17
【问题描述】:
我是 Phalcon php 框架的新手,我遇到了这个问题。我希望每个模块都有简单的视图。例如:
用户的视图会说:“你好,这是我的用户”
articles 的视图将有:'this are all the items'
所以在这种情况下,我需要通用布局(或其他),我的头部、css 标签、页脚、导航栏等都在哪里。
为此我关注了this repo。
所以...在我的/modules/Home/module.php 我有:
$di['view'] = function() {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->setLayoutsDir('../../common/layouts/');
$view->setTemplateAfter('main');
return $view;
};
在/modules/common/layouts/main.phtml 我有我所有的 html、heads 等。
在/modules/Home/views/index.phtml我有“你好”
在/modules/Home/views/edit.phtml我有“编辑我的主屏幕”
现在当我转到“/”(根目录)时,它会调用 home/index,而我只看到“你好”,没有其他内容。
这样可以吗?
【问题讨论】: