cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR] Include controller in view

Open Cmssspl opened this issue 13 years ago • 5 comments

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 ]) }}

Cmssspl avatar Apr 29 '13 12:04 Cmssspl

Works as

View::getRender (string $controllerName, string $actionName, [array $params])

Further set the rendering level to only view,

Cmssspl avatar May 01 '13 14:05 Cmssspl

It's better be normal widget solution, but as a quick solution I like the idea :+1:

roman-kulish avatar May 10 '13 01:05 roman-kulish

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']) }}

ghost avatar May 22 '13 03:05 ghost

This doesn't run controller, only renders view. :-(

Cmssspl avatar May 22 '13 18:05 Cmssspl

I'm closing this issue due to the lack of any reaction. I'll open it again if the need arises

sergeyklay avatar Jul 17 '17 14:07 sergeyklay