Get a blank page after run view getrender

Hello,

I try to create email template to user to edit the template and see the preview, I will show 2 variable which is $template that get a collect-review.volt content and $template-rendered that rendered by volt engine to display the preview.

After run getRender, I get a blank page. Is it possible to do this?

public function getTemplate()
{
            $params = array();
    $parameters = array_merge(array(
        'name' => 'myname',
    ), $params);

    return $this->view->getRender('emailtemplates', 'collect_review', $parameters, function($view){
        $view->setRenderLevel(View::LEVEL_LAYOUT);
    });

}

public function collectTemplateAction()
{
         $auth = $this->session->get('auth');
         $shop = Shops::findByOwner($auth[id]);
         $this->view->setVar("shop", $shop);
         $this->view->setVar("name", 'warut');

         $template = file_get_contents('../apps/frontend/views/emailtemplates/collect-review.volt');

         $template_rendered = $this->getTemplate();
         //echo 'aa'.$template_rendered;

         $this->view->setVar("template", $template);
         //$this->view->setVar("template_rendered", $template_rendered);
    //$this->view->disable();
}

Thanks,



8.1k
edited Apr '15

by the way if you use phalcon model and you wrote wrong syntax it will not render anything so i guess

$shop = Shops::findByOwner($auth[id]); change it to $shop = Shops::findFirstByOwner($auth[id]);

follow phalcon 's document http://docs.phalconphp.com/en/latest/reference/models.html

p.s sorry for my bad english and i can't post mark down I don't know why :(



4.3k

Hello xeleniumz, thanks for your reply but $shop is working well (get all shops with user id). If I comment $template_rendered = $this->getTemplate() to skip running getTemplate function page will display normally but after run getTemplate (running $this->view->getRender) my page not return anyting.



8.1k
edited Apr '15

thank you for new knowledge , I just know we can get all query which findby haha , ok may be the problem is from your render function , try to disable some layout and render replace it http://docs.phalconphp.com/en/latest/reference/views.html#disabling-render-levels

In my case if i want to hierarchical rendering with other layout I did like this

my controller

    use Phalcon\Mvc\View;
    class TopupController extends ControllerBase {
    public function initialize() {
        parent::initialize();
        $this->view->disableLevel(View::LEVEL_MAIN_LAYOUT);
    }
    public function indexAction(){

    }

and in my view

    <?php $this->partial("topup/header") ?>
        content
    <?php $this->partial("topup/footer") ?>

hope this answer may be your guidline p.s. sry for my bad english but I try to help you :)