Is it possible to use views like this way


First of all English is not my primary language and I'm not sure about to explain my problem properly, I thank you for your patience.

I'm trying to move from ZF to pHalcon. However I had some diffuclties. To be honest I already archieve this. However it looks like a bit hackish. (freeze the falcon and use old clasess). And I just want more offical way to archieve this.

For a long time I use GLOBAL output storages to display pages.

Let say I had standar 3col layout.


Nav Content ADS


In my curent working way system has default layout (look like above) and may hav use different layout, either by programmer (for static controllers) or my have user configurable (dynamc page renderer) layouts.

(for example leftcol layout


Nav Content ADS



Also I had dynamic page renderer, which user may choose any kind of plugin to put those predefined locations via viusal tools. Plugins also may send output in any location..

it was so simple (to me).

I just store template output in location holder.


this will send my ouput in to NAV holder.

And at end of the page execution. I fetch the all output then print in proper locations.

php echo t::$NAV;

However, I can't find to use this model in pHalcon way. Is there any way to archieve this ?

My Best Regards



I think the best way to solve this issue is with volt templates ( You can create a layout master template, and then define blocks of contents that will be filled with new contents generated by the controllers. You also can use the "include" tag to include the content from another volt template, like a separated "navigation.volt" template.

For other examples on how you can use the volt template structures to easily produce complex templates using volt structure, please visit:


Hello thanks for reply.

My system works on controller level. Layouts does not know anything about the content. Naming them navigation etc just make sense. You can add more location or change names.

I'm just creating content somewhere im my code and I set the destination of the content at rendering time. Then inject that content in page, at rendering time.

If I understood correctly, pHalcon uses pre determined template hiearchy, which perfectly fit something like wordpress page etc. However my system works like typo3 and it was chaotic.

I just do not want to use strict template policy.

You can disable template hierarchy loading:

Or define just what type of rendering levels you want for your application:

For me, the best mode is Action View rendering level and use volt template inheritance to extend the main layout template:

Forgot to add this. If you want to setup by default witch Rendering Level you want, you can do this with setRenderLevel while setting up the view in index.php :

The code highlight bellow will have weird colors in variable names, just select all code to see it correctly:

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

                $view = new \Phalcon\Mvc\View();
                $view->setViewsDir(__DIR__ . $config->application->viewsDir);
                    '.volt' => 'volt',

                return $view;