I've just gotten past a bit of the learning curve with clips, so I thought I'd share my current solution.
Basically, I wanted a re-useable CMenu sidebar widget for various departments of my site.
My controller looks like this (I'm using actions too):
class ExampleController extends Controller
{
...
public function actions()
{
return array(...
'stories' => array(
'class' => 'application.controllers.example.StoriesAction',
),
);
}
}
Then, my StoriesAction (controllers/example/StoriesAction.php) looks like this.
class StoriesAction extends CAction
{
public function run()
{
...
$this->controller->renderPartial("_sidebar");
$this->controller->layout = 'sidebarleft';
$this->controller->render("stories");
}
}
Then, in views/example/_sidebar.php:
$this->beginClip('sidebar');
$this->widget('zii.widgets.CMenu', array(
'activeCssClass'=>'active',
'itemCssClass' => 'item',
...
));
$this->endClip();
The sidebarleft layout contains, among other things:
<?php echo $this->clips['sidebar']; ?>
<?php echo $content; ?>
This way, each controller can have its own sidebar, written as a single script, which is rendered into a clip and used in a global layout. Niiice.