title: Setting Yii viewPath conditionally in controller action
body: <p>I need to set viewPath dynamically based on some conditions in a controller action. I am aware of a method by placing a method called getViewPath() in your controller as below:</p>
  
  <pre><code>public function getViewPath() {
    $controllername = $this-&gt;getId();
    $newPath = "application.views.extra";
    $newPath = YiiBase::getPathOfAlias($newPath);
      return $newPath;
  }
  </code></pre>
  
  <p>But as i said earlier i need to set viewPath based on a condition. like this:</p>
  
  <pre><code>public function actionView($section) {
     switch ($section) {
       case 'yoga':
         $viewpath = 'yoga';
       break;
  
        case 'cycling':
          $viewpath = 'cycling';
        break;
     }
  
      // Now this should render from either:
      1.  protected/views/yoga/  
      2.  protected/views/cycling/
       $this-&gt;render('view');
  }
  </code></pre>
  
  <p>Controller class has getViewPath() but not setViewPath() and viewPath property is also readonly.</p>
  
  <p>Appreciate any help with this.</p>