Theme Specific Controller Possible?

I have different actions based on which themes is selected.

For example Theme1 has ‘site/actionTheme1ActionA’ and Theme2 has ‘site/actionTheme2ActionB’

Ideally, I don’t want to clutter every action from every theme in the one protected/controllers/SiteController.php

It’d be cool if I could do something like ‘themes\Theme1\controllers\Theme1SiteController.php’ which would be something like “class Theme1SiteController extends SiteController …”

If Theme2 is selected, I want ‘site/actionTheme1ActionA’ to not resolve. Does this make sense?

I’ve been reading topics and searching and reading some more… But I’m not seeing a good solution.

Appreciate anyone’s time that might try to offer me assistance.

Feel free to ask for clarification if I’m not being clear.

my be like this?? differnent theme

Thank you for offering that as a solution. Using conditionals in the SiteController is an option, it just makes for a rather LARGE/long SiteController, if I have 20 themes then I have to add switches and cases all over the place. I’m trying to do it in a more OOP way if possible. Again, thanks for taking the time to link that thread

i think the best way solution is you want to defind the defaultcontroller on index b[/b]


then after create the IndexController on module that extends the FrontCoreConteller apply the defult layout is main…


class IndexController extends FrontCoreController {


     * Declares class-based actions.


    public function actions() {

        return array(

            // captcha action renders the CAPTCHA image displayed on the contact page

            'captcha' => array(

                'class' => 'CCaptchaAction',

                'backColor' => 0xFFFFFF,


            // page action renders "static" pages stored under 'protected/views/site/pages'

            // They can be accessed via: index.php?r=site/page&view=FileName

            'page' => array(

                'class' => 'CViewAction',





     * This is the action to handle external exceptions.


    public function actionError() {

        if ($error = Yii::app()->errorHandler->error) {

            if (Yii::app()->request->isAjaxRequest)

                echo $error['message'];


                $this->render('error', $error);



    public function actionIndex() {








 * Controller is the customized base controller class.

 * All controller classes for this application should extend from this base class.


class FrontCoreController extends GxController


	public $layout='main';

	public function init()






Finally you want to create the layout on modules folder


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title><?php echo SystemConfig::getValue('site_title');?></title>

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />

<!--[if IE]><script src="js/html5.js"></script><![endif]-->



	 <section class="wapper">

             <?php //p( yii::app()->customer)  ?>

	 		<?php echo $this->renderPartial('//layouts/header');?>

	 		<?php //echo $this->renderPartial('//layouts/slider');?>


	 		<?php echo $content;?>

         	        <?php echo $this->renderPartial('//layouts/footer');?>





in this code every time call a default controller is index and action is call index so all modules default layout is main.php and write any code on index action fetch the data on

<?php echo $content ; ?>

i hope you got the my point… :rolleyes:

more references please see this link

Thank you Ankit Modi for reading and responding.

To me, you’re showing me how to use different layouts. Correct?

That would be handy if that were my goal. I guess I’m terrible at either understanding your solution or explaining what I’m trying to do. Let me say it another way.

AND THANK YOU, for trying to help!

I’m trying to have

When theme1 is chosen

class Theme1Controller extends SiteController


   public function actionTheme1Action1()





And when theme2 is chosen

class Theme2Controller extends SiteController


   public function actionTheme2Action2()





yes you are right in my last post i will call a different layout

and thanks for your last post (theme is chosen)