1
继承的接缝在伏模板中不起作用。在使用Volt与phalcon时遇到问题
尔康版本是0.6.1
有一个文件结构:
- 的意见/
- 指数/
- 的index.html
- 布局/
- main.html中
- 指数/
- 的index.php
的index.php:
<?php
$di = new Phalcon\DI\FactoryDefault();
$di->set('volt', function ($view, $di){
return new Phalcon\Mvc\View\Engine\Volt($view, $di);
});
$view = new \Phalcon\Mvc\View();
$view->setViewsDir("views/");
$view->registerEngines(array(
".html" => 'volt'
));
$view->setDi($di);
$view->start();
$view->render("index", 'index');
$view->finish();
echo $view->getContent();
视图/索引/ index.html中
{% extends "layouts/main.html" %}
{% block content %}
<h2>Index</h2>
{% endblock %}
的意见/布局/ main.html中
<h1>Main</h1>
{% block content %}
Not index
{% endblock %}
当我运行php index.php
我得到:
未捕获的异常 '尔康\的mvc \查看\异常' 与消息“模板view to extend'layouts/main.html'does not exist'
我的理解根应该是views文件夹。就像它在枝杈中一样。所以看起来像一个错误。 –
'{%extends“views/layouts/main.html”%}' - 没有工作 –
@E_p先行之路:https://github.com/phalcon/cphalcon/issues/208 –