Module models (preload/import)

Hi there,

When I use a forum module, it would be nice, if i could do something like:

if (forum is enabled) {

Use models from;


I can’t figure out how to do this, it seems that the CWebModule::init() is only run, if a action within the module is called.


I guess that you should use some options.

Did you tried to use like this:


Think I got it now:




If forum is a submodule to community.


returns true if the module is installed.


I don’t quite understand the difference preload and import around modules

I was testing an internationalisation module which I declared

it was based on a component

it wasn’t working untill I preloaded the needed component

could someone please shed some light on the differences in the loading process of modules , preload , import ?


Modules are independant, they add funcionality to the application, but the application should not depend on them, say a users module, adds the posibility to manage users, login, etc. but the application could run wihtout it.

When you preload something it gets (always) automatically imported when creating the application.

But you can use import, when you need a class that will be only used in certain cases:

Say you have a class that inherits from another,

class A extends B{}

if B is not preimported then you need to import it before use it.


class A extends B{}