class myWidget extends CWidget
{
public function init()
{
ob_start();
}
public function run()
{
// do other Stuff
// do render
??->renderPartial("viewXY");
}
}
Please be careful, in this way, if you call your widget from multiple controllers each of your controller must point to the same correct view file.
For example, if you have a post controller and you call your widget from within, the system will look for a view file located in /views/post/my-view-file.php
If you call it from a comment controller the system will look for a view located in /views/comment/my-view-file.php and of course it won’t find it and throw an error.
The above code will always use the “my-view-file.php” located in the post folder, doesn’t matter from which controller you call it.
Or you can remember that the widgets are self contained, therefore these should not have any controller dependencies, so you will place your view file, as i said before: