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]


'defaultController'=>'index/index',

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


<?php


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'];

            else

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

        }

    }


    public function actionIndex() {

    }

}

[b]

FrontCoreConterller.php

[/b]


<?php

/**

 * 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()

	{

		parent::init();

	}

	

}

Finally you want to create the layout on modules folder

/views/layouts/main.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>


<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]-->

</head>


<body>

	 <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');?>

			

     </section>

</body>

</html>




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

http://mushfiq.com/2011/05/30/creating-a-yii-application-theme-from-a-html-template/

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()

   {

      $this->render('theme1_action1');

   }


}



And when theme2 is chosen




class Theme2Controller extends SiteController

{

   public function actionTheme2Action2()

   {

      $this->render('theme2_action2');

   }

}



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

and thanks for your last post (theme is chosen)