title: Yii, I am trying to have a dynamic layout for my views
body: <p>I want different views to render using one layout(<strong>sections.php</strong>), but the layout should load a different background for each view. How can i achieve this without using 4 different layouts for each view.</p>
  
  <p><strong>protected/views/site</strong><br>
    <ul>
     - index.php<br>
    - about.php<br>
    - product.php<br>
    - brands.php<br>
  </ul>
  <strong>protected/views/layout</strong>
    <ul> 
    - sections.php
  </ul></p>
  
  <pre><code>&lt;html&gt; 
     &lt;head&gt;&lt;/head&gt;
     &lt;body&gt;
        &lt;div id= "viewname"&gt;
         &lt;ul&gt; 
            &lt;li&gt;Home&lt;/li&gt;
            &lt;li&gt;about&lt;/li&gt;
            &lt;li&gt;products&lt;/li&gt;
            &lt;li&gt;brands&lt;/li&gt;
         &lt;/ul&gt;
         &lt;!--I want to load different bg for this div for each view---&gt; 
         &lt;!--there's a lot of content that comes here, i dont want to do it in every page---&gt; 
         &lt;!--how can i load the class name for this div dynamically if possible--&gt;
        &lt;/div&gt;
        &lt;div class=section-cont&gt;
            &lt;?php echo $content; ?&gt;
        &lt;/div&gt;
  
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>my css</p>
  
  <pre><code>#about
    {
      .... 
     background-image: ('../img/about.jpg')       
    }
  #product
    {
      .... 
     background-image: ('../img/product.jpg')       
    }
  #brands
    {
      .... 
     background-image: ('../img/brands.jpg')       
    }
  </code></pre>
  
  <p>myController</p>
  
  <pre><code> class SiteController extends Controller
   {
     public function actionAbout()
     {
      $this-&gt;layout = "sections";
      $this-&gt;render('about');
     }
    //functions for other views is similar to above 
  </code></pre>