Friday, September 12, 2014

Cakephp : Reading an element content from with in a component

If you ever need to read the content (rendered of otherwise) of an element from component this is how to do it.
This is based on V 2.3

//vie file in /View/Elements/templates/prolfile.ctp

$view = new View();
$view->set(compact('data', $data)); //$data will be pass in to the element.  
$view->viewPath = 'Elements'; 

$content = $view->element('templates/profile');



No comments: