php - Phalcon volt include another volt -
so have volt code:
views/administrator/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 exist , has content.
but when run code, have error
view '/var/www/html/phalcon-dash/app/config/../../app/views/administrator/moderator-form-user.volt' not found in views directory
i took out user['role']
, use {% include "administrator/moderator-form-user.volt" %}
, works (user['role'] = 'moderator')
can explain me why happens , how work around it, i'll need implement more roles in future, , don't want have multiple if-else in volt
update
this answer problem
have tried partial? {{ partial("administrator/" ~ user['role'] ~ "-form-user") }}
i'm guessing not right views directory. check out well?
from controller, can try views directory; $this->view->getviewsdir()
Comments
Post a Comment