How to reference a module parameter anywhere

the condition if(!Shop::getCartContent()) is used in the shop module.

How would you use it anywhere?? Is there a way to access it like: Yii::app()->user->isGuest

Basically what I’m trying to accomplish is getting back to the shopping cart after the user has logged in. Right now, it just going back to the main page: $this->redirect(Yii::app()->user->returnUrl);

I’ve tried a bunch of approaches the latest being:


if(Yii::app()->modules->shop->getCartContent())

but that results in: Fatal error: Call to a member function getCartContent() on a non-object in C:\xampp\htdocs\lightningCat\protected\controllers\SiteController.php on line 101

try this :

         Yii::app()->getModule('shop');// this load the  shop module and return it to you;

then some class under this module can be accessed; please refer to the init function of XXXModule ;

if code Shop::getCartContent() you used , seems that the getCartContent is a static function of Shop class

; then try access it;




          //if you access shop module from another module or in app scope ,not in shop module try this:

         

           Yii::app()->getModule('shop'); //firstly load the shop module; this cause the necessary class dir                //imported  then you can  access the class from xxx module ;

           print_r(Shop::getCartContent());

         




just try it , i am not sure my answer is wright :D ;

by the way if you want use some class from another but current module you can import it first (Yii::import(‘moduleId.components.SomeClass’)); then use it !