How to render code in phalcon view

北慕城南 提交于 2019-12-12 02:33:18

问题


$view->start();
$view->render("products", "list");
$view->finish();

above is show how to render from a file, I wonder is it possible to render a string/code with this method?

$view->start();
$view->renderstring("<?php echo $this->url->get('users/list') ?>");
$view->finish();

回答1:


You can use 'setContent' to set the view content:

$view->setContent('<h1>hello</h1>');

But this functions receives the final content to the view. So to do the example you gave the correct use would be:

$output = 'The link is: <a href="'.$this->url->get('users/list').'">link</a>';
$this->view->setContent( $output );
echo $this->view->getContent();


来源:https://stackoverflow.com/questions/18486217/how-to-render-code-in-phalcon-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!