所以我有这个伏特代码:
意见/管理员/index.volt
{{ content() }}
{% set user = session.get('user') %}
<br />
<div class="row">
<div class="col-xs-12 col-md-12 col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<a data-toggle="collapse" href="#container_userForm">
<span class="glyphicon glyphicon-asterisk"></span>
<b style="color: green;">New user</b>
</a>
</div>
<div id="container_userForm" class="panel-collapse collapse">
<div class="panel-body">
{% include "administrator/" ~ user['role'] ~ "-form-user.volt" %}
</div> <!-- end panel body -->
</div>
</div>
</div>
</div> <!-- end row -->
views/administrator/moderator-form-user.volt 存在并且有一些内容。
但是当我运行代码时,我有这个错误
View '/var/www/html/phalcon-dash/app/config/../../app/views/administrator/moderator-form-user.volt' was not found in the views directory
我取出user['role']
并使用{% include "administrator/moderator-form-user.volt" %}
,它可以正常工作(user['role'] = 'moderator')
任何人都可以向我解释它为什么会发生以及如何解决它,我将来需要实现更多角色,而且我不希望有多个 if-else in volt
更新
这是问题的答案