title: Dynamic layout in Yii
body: <p>I have a Yii application and in the layout I have a static sidebar. I would like to change the content of the sidebar depending on the controller action, or the view. At the moment, in the <code>views/layouts/main.php</code> file, I have a sidebar defined as:</p>
  
  <pre><code>&lt;div class="sidebar"&gt;hello!&lt;/div&gt;
  </code></pre>
  
  <p>When the controller is <code>image</code> and the action is <code>test</code>, I would like to display this:</p>
  
  <pre><code>&lt;div class="sidebar"&gt;Created at &lt;? echo $image-&gt;created_at; ?&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The $image object is defined in the <code>image</code> controller and the <code>test</code> action.</p>
  
  <p>In short, I would like to display a sidebar when the controller is <code>image</code> and the action is <code>test</code>, however, I would not like to have a different layout entirely. How can I accomplish this?</p>