Search code examples
yiiportlet

Get portlet as HTML variable in Controller?


I have a controller called CartController.php and I have a portlet/view called _cartItem.php. How can I programatically render the portlet to a PHP variable so I can return it to another function? Ie. Do something like this:

$data = new stdClass();
$data->productID = 123;
$data->title = 'My Title';

$HTML = someVoodoo('_cartItem', $data);

return $HTML;

Any ideas?


Solution

  • Have you tried;

    $HTML = $this->renderInternal('_cartItem', $data, true);
    

    Here's a link to renderInternal(): http://www.yiiframework.com/doc/api/1.1/CBaseController#renderInternal-detail