Phalcon View Problem

About the View of Phalcon. I wanted to make a menu generator. And i want to Compile Two Volt files in to String and combine this string. After that, i just wanted to simply echo or return this string to View(This string will be in RAW HTML code).

And i didn't found any function to support it. If I make new View Object and Pick the Volt by $view->pick. it's not converting to String but stays in object.

So...Any idea how to do it? guys?

Two options come to my mind:

1) Render the views into a variable (string)

$viewParams = [
    'param1' => '....',
    'param2' => '....',

// Render view into a variable
$html = $this->view->getRender('yourTemplateDir', 'yourTemplateName', $viewParams, function($view) {

More info on view render levels:

2) Use volt view fragments

{% cache "sidebar" %}
    <!-- generate this content is slow so we are going to cache it -->
{% endcache %}

More info here:



But Still not working quite well here.

The Return of the First Code is empty ' '.

I used this view in my own class which extends \Phalcon....\Component class .

use \Phalcon\Mvc\User\Component;

use \Phalcon\Mvc\View;

use Phalcon\Session\Adapter\Redis;

          class MainMenu extends Component {

public $MenuCfg; protected $cfgHash; protected $redis; public .... }

Any Ideas or Can you teach me some thing about this View thing? I used Laravel and some other framework stuff before. But not quite understand this volt thing. It's quite similar to Twig or Blade but not exactlly same the way the View Generated.