Create themes

I need to create themes for my system, and for this I need this functionality. Volt does not support extends dynamically, how can I implement this functionality?

{% extends "@App/layout.html.twig" %}

http://symfony.com/doc/current/templating/namespaced%5paths.html



1.5k

Volt does support this. Comming from Symfony I find Volt almost a one on one twin with Twig.

{% extends "layout.volt" %}

{% block title %} Project {% endblock %}
{% block pagehead %} Project - index {% endblock %}

{% block flashMessages %} {{ super() }} {% endblock %}

{% block content %}
<div class="box">
    <div class="box-header width-border">
        <a href="{{ url("project/new") }}" class="btn btn-primary pull-right primary-add"><i class="fa fa-plus"></i> <span>Create Project</span></a>
    </div>

    <div class="box-body">

        <div class="row">
            <div class="col-xs-12">

                <table id="projectTable" class="table table-bordered table-hover responsive">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Client</th>
                            <th>Name</th>
                            <th>Status</th>
                            <th>Delivered</th>
                            <th>Last Modified</th>
                            <th>Options</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for project in projects %}
                        <tr>
                            <td width="80px" >{{ project.id }}</td>
                            <td>{{ project.client_id }}</td>
                            <td>{{ project.name }}</td>
                            <td width="100px" >{{ project.project_status_id }}</td>
                            <td width="80px" >{% if project.delivered %} Yes {% else %} No {%  endif %}</td>
                            <td width="150px" >{{ project.modified }}</td>
                            <td width="120px">
                                <a class="btn btn-default btn-sm" href="{{ url("timeregistration/new/" ~ project.id) }}" title="add time" ><i class="fa fa-plus"></i></a>
                                <a class="btn btn-default btn-sm" href="{{ url("project/edit/" ~ project.id) }}" title="update" ><i class="fa fa-pencil"></i></a>
                                <a class="btn btn-default btn-sm" href="{{ url("project/confirm/" ~ project.id) }}" title="delete" ><i class="fa fa-trash"></i></a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                    <tfoot>
                        <tr>
                            <th>#</th>
                            <th>Client</th>
                            <th>Name</th>
                            <th>Status</th>
                            <th>Delivered</th>
                            <th>Last Modified</th>
                            <th>Options</th>
                        </tr>
                    </tfoot>
               </table>

            </div>
        </div>

    </div>
</div>
{% endblock %}

{% block javascripts %}
<script type="text/javascript">
    $(function(){
        $("#projectTable").DataTable();
    });
</script>
{% endblock %}

I mean to extend dynamically. Look at the symbol @ in extends



402

I'v you tried something like this :

{% extends router.getNamespace() ~ "/layout.html.twig" %}

or something like that :

{{ set namespace = router.getNamespace() }}
{% extends  namespace ~ "/layout.html.twig" %}

https://forum.phalconphp.com/discussion/2131/get-controller-and-action-name-in-a-volt-template-



1.5k
edited 1d ago

I mean to extend dynamically. Look at the symbol @ in extends

Have you tried a variable in extending?

Or do you mean that you want to include a part which is a result of a action dynamically ? I think partials is used for that in which you could also use variables

```php {{ partial('user/info',['somename':'somevalue'] }} ```