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

Is there a way to execute code after View has compiled Volt template.

I am using parts of the phalcon in my own custom framework and I have a question regarding VIews and Volt.

I need to perform additional manipulation on the compiled template, so after view calls volt and compiles the template (if it hasn't been compiled yet) I need a way to perform some more functionality.

For performance reasons I don't want to be performing this additional functionality after every view rendering, so I need either some kind of event (if volt or view issues one after succesful compilation of template) or some another way to intercept the volt compile call.

I was looking in the documentation for View , Volt and Volt Compiler but didn't see any events or callbacks that would allow for this, did I miss something ?

I was also thinking of possibly extending Volt and Volt Compiler and intercepting the compile code that way but without the view and volt source code it's hard to see which method I should be overriding.

Any idea on how to acomplish this ?

Thanks

edited Mar '14

Why not use 'afterRenderView' event?

$eventsManager->attach("view:afterRenderView", function($event, $view) {
        if ($view->getActiveRenderPath() == 'Your view full path, or for example your view with additional extension *.special.volt'){
         // Your code...
        }
    });

But isn't view:afterRenderView issued after every view rendering ? I want an event which is issued only after template has been compiled.

Oh, sorry. There is no such event... you will need to extend volt class and rewrite it to your logic... Btw what you want to do with compiled templates?