We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Flash messages not displaying in volt

I'm using Phalcon 2.0.6 (win7) with multiple inheritance templates

How can I display the flash messages?

This doesn't work

// service
use Phalcon\Flash\Direct as Flash;
use Phalcon\Flash\Session as FlashSession;

$di->setShared("session", function () {
    $session = new SessionAdapter();
    $session->start();

    return $session;
});

$di->set("flash", function () {
    $flash = new Flash();
    $flash->setImplicitFlush(false);

    return $flash;
});

$di->set("flashSession", function () {
    $flashSession = new FlashSession();
    $flashSession->setImplicitFlush(false);

    return $flashSession;
});

// controller
$this->flashSession->error('Flash Error!!!');
$this->flash->error('Direct Error!!!');

//$this->flashSession()->getMessages(); //works, return an array with messages
    <h1>Main layout</h1>

    {# {{ flashSession.getMessages() }} return null #}

    {{ flash.output() }}
    {{ flashSession.output() }}

    {% block content %}

    {% endblock %}

I have looked a lot of topics and issues but I did not found the solution.



58.4k

Hey

You tried add this before it

{{ this.flashSession.output() }}

My website is working at here



2.0k

Hey

You tried add this before it

{{ this.flashSession.output() }}

My website is working at here

Thanks. But the result is not changed. When I call the {{ content() }} method, flash messages works, but the main layout is rendered twice.



2.0k
edited Aug '15

If it helps for someone, direct messages working in linux (phalcon 2.0.5), but the session messages still not working.