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

Function to print columns

hello!

As this problem can be realized. In the insert template function {{leftblock ()}} and loading it into the sidebar blocks, depending on action?

I recorded a new feature: '''php $ compiler = $ volt-> getCompiler (); $ compiler-> addFunction ('leftblock', function ($ resolvedArgs, $ exprArgs) { return 'ControllerBase :: leftblock ('. $ resolvedArgs. ')'; }); ''' But it necessary to transfer the data from templates or action?

You can place the logic behind leftBlock in a user component that can be called from views and controllers:

class Blocks
{
    public static function left($args)
    {
        //...
        return $html;
    }
}

Using it in functions:

$compiler = $volt->getCompiler();
$compiler->addFunction('leftblock', function ($resolvedArgs, $exprArgs) {
     return 'Blocks :: left('. $resolvedArgs. ')';
});

Using it in controllers:

<?php

class SomeController
{
   public function someAction()
   {
       Blocks::left();
   }
}

Thank you! So I started to do, but stopped at the desired template and uploading the data into it.

How to transfer data figured out

$this->view->setVar ("value", $ value);

Here's how to load template?

And I returned error:

Class 'BlockData' not found in 'cache template path' Cannot redeclare class Namespace\Models\BlockData in class-path\BlockData.php

In template add: <div class="span3"> {{ leftblock() }} </div>

In IndexController add: use Namespace\Models\BlockData;