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.
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
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
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');
}
}