Replies: 3 comments 2 replies
-
Off the top of my head, I suppose in your last action you could disable the view, then just However, I think you're mis-using how controllers & actions are supposed to work. Only 1 action should be fully executed per request - the whole system is set up that way. If you're finding the output (and consequently the logic) from an action is needed in multiple places, you should move the logic into a component. |
Beta Was this translation helpful? Give feedback.
-
hmm... i found old code of mine and i accomplish that way: $view = clone $this->view;
$view->start();
$view->setLayout('emails');
$view->setVars($params);
$view->render('_emails', $template);
$view->finish();
$message = $view->getContent(); |
Beta Was this translation helpful? Give feedback.
-
You can try to use Simple View. With it, it is possible to pick template, pass variables and render into variable or output to the browser. |
Beta Was this translation helpful? Give feedback.
-
I have the following code below which works as I suppose it should. I would like to know if there is a way to just return the view contents without actually showing the view on the browser. At the moment, the dispatcher runs and targets the controller/action which has a view associated with that action. At the end of the dispatch, that view echoes in the browser.
I would like to be able to run this method multiple times with different contoller/actions and just collect the view contents in order to finally send them to another view where they will be combined.
Collecting the contents succeed but the ultimate view cant be displayed as the page ends up showing the view of the last action the dispatch hit. Any help in stopping that view from actually loading?
getData(){
$dispatcher = $application->dispatcher;
$dispatcher->setNamespaceName(xxxxx);
$dispatcher->setModuleName(xxxxx);
$dispatcher->setControllerName(xxxxx);
$dispatcher->setActionName(xxxxx);
/**
* @var \Phalcon\Mvc\ViewInterface $view
*/
$view = $dispatcher->dispatch()->view;
Beta Was this translation helpful? Give feedback.
All reactions