Last active
December 22, 2015 11:59
-
-
Save rootbear/6469750 to your computer and use it in GitHub Desktop.
Access to other modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//config 3rd party component | |
'components'=>array( | |
... | |
'mailer'=>array( | |
'class'=>'application.extensions.mailer.EMailer', | |
'Mailer'=>'smtp', | |
'Host'=>'yourhost', | |
'SMTPAuth'=>true, | |
'Username'=>'smtpuser', | |
'Password'=>'smtppass', | |
), | |
), | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//To access a different module or a model within a different module, use | |
Yii::app()->getModule('moduleName'); | |
//You can then use models from that module in the usual way. | |
//within module | |
echo Yii::app()->controller->module->property_name; | |
//in module file | |
public function property_name(){ | |
return 'value_of_property' | |
} | |
echo Yii::app()->controller->id; //or | |
echo Yii::app()->getController()->getId(); | |
//$this->id here $this refers to current controller | |
To get method/action name | |
echo Yii::app()->controller->action->id; | |
//You can get action name in controller | |
echo $this->action->id; | |
//To get module name | |
echo Yii::app()->controller->module->id; | |
$this->module->id | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//in config | |
'urlManager' => array( | |
'urlFormat' => 'path', | |
'showScriptName' => false, | |
'rules' => array( | |
'user/passwordreset/t/<someString:\w+>' => 'user/passwordReset/' | |
), | |
//the URL : user/passwordreset/t/asdagfasgas | |
//Inside UserController have a function | |
actionPasswordReset($someString){ | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment