How to Get the View Template Content as a String in Variable

How to Get the View Template Content as a String in Variable?

This is For Cakephp, It Loads the Template Content as a string in a variable.

$view = new View($this, false);
$view->set(compact('parameter1', $parameter1));
$view->set(compact('parameter2', $parameter2));
$html = $view->render('view_page_name');

We Can Also Use this,

//==================================
// get the html content
//==================================
$view = new View($this, false);
$view->set('result', $result);

$html = $view->render('ajax_page_name');

Leave a Comment