cphalcon
cphalcon copied to clipboard
[NFR] Include controller in view
Include controller in view, example of symfony:
{{ render(controller('AcmeArticleBundle:Article:recentArticles', { 'max': 3 })) }}
This could be like that in volts:
{{ render('controller/action', [ ARRAY params ]) }}
Works as
View::getRender (string $controllerName, string $actionName, [array $params])
Further set the rendering level to only view,
It's better be normal widget solution, but as a quick solution I like the idea :+1:
You can use:
$compiler = $volt->getCompiler();
$compiler->addFunction('render', function($resolvedParams) {
return '$this->view->getRender(' . $resolvedParams . ', function ($view) { $view->setRenderLevel(Phalcon\Mvc\View::LEVEL_ACTION_VIEW) })';
});
Usage:
{{ render('mycontroller', 'myaction', ['param1', 'param2']) }}
This doesn't run controller, only renders view. :-(
I'm closing this issue due to the lack of any reaction. I'll open it again if the need arises