How to use Module

I was going through the guide and stuck up at one place

In the above line controller->module->postPerPage do we have to replace controller with controllerID and module with moduleID


That’s literally what you need to write:


That will work if you’re in that module.

If you’re not in a module Yii::app()->controller->module will be null.

Hi Jacmoe,

Can you explain more about accessing a module’s property in a site level default controller?

Beside using Yii::app()->getModule("MODULE_NAME")->MODULE_PROPERTY;

Is there anyway we can use something like the following?



Yii::app()->controller->module refers to the current module, so you can use that instead of [color="#1C2837"][size="2"]Yii::app()->getModule("MODULE_NAME").[/size][/color]

[color="#1C2837"][size=“2”]It’s just a short-hand function. :)[/size][/color]

[color="#1C2837"] [/color]

[size=“2”][color="#1c2837"]You can’t expect to be able to access other modules using that function, of course since it refers to the active module.[/color][/size]

[size=“2”][color="#1c2837"]If you need to access other modules, or if you are not ‘in’ a module, then you need to use the getModule function.[/color][/size]

Hi Jacmoe,

Thanks for your reply, i am well understood. :lol:

Hye friends… Now only am creating the module from gii. how can i access the module. I cant open it. The module files are placed in the module folder but i can’t open it in the browser. please help me out how can i access it and work… and paste the address for accessing the module.