Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Render Level in Volt

Is Volt template provide Render Levels?

I have some code:

{# layout.volt #}
<!DOCTYPE html>
    <meta charset="UTF-8" />
    <title>{% block title %}Welcome!{% endblock %}</title>

    <link href="/css/style.css" type="text/css" rel="stylesheet" />
    {% block CSS %}{% endblock %}

    <script src="/js/jquery-1.11.0.min.js"></script>
    <script src="/js/jquery-ui.min.js"></script>
    {% block JS %}{% endblock %}
<div id="jsContent">
    {% block content %}
    {% endblock %}
{# NewEvent.volt #}
{% extends "layout.volt" %}

{% block title %}title{% endblock %}

{% block JS %}
    <script src="/js/backend/some.js"></script>
{% endblock %}

{% block content %}
    <form action="{{ form.getAction() }}" method="post" class="create-entity">
{% endblock %}

namespace Backend\Controllers;

class SomeController extends ControllerBase
    public function newEventAction()
        $form = new EventForm();

        //this not works

        $this->view->setVar('form', $form);

And finally, the output is a full page, with layout content.

How to make it work, without layout, only "block content"?

edited Apr '15

By default phalcon knows to render each level so you wouldn't need to extend the main layout. Also when you extend the main layout it renders it even you set to render only the action, because is part of action. Try removing

{% extends "layout.volt" %}


Thank you. I read docs again and saw that my layout named as "layout.volt". While debugging I saw "_mainView = "index""...

By the word :

        $di->set('view', function () {

            $view = new View();

             * Added this

                ->setViewsDir(__DIR__ . '/views/')
                    '.volt'  => function (View $view, $di) {
                            $volt = new Volt($view, $di );

                                'compiledPath'      => __DIR__ . '/cache/',
                                'compiledSeparator' => '_',
                                'compileAlways'     => true,
                            return $volt;
                    '.phtml' => 'Phalcon\Mvc\View\Engine\Php'

            return $view;
        }, true);