20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

forum/<br />

ForumModule.php<br />

components/<br />

views/<br />

controllers/<br />

DefaultController.php<br />

extensions/<br />

models/<br />

views/<br />

layouts/<br />

default/<br />

index.php<br />

the module class file<br />

containing reusable user components<br />

containing view files for widgets<br />

containing controller class files<br />

the default controller class file<br />

containing third-party extensions<br />

containing model class files<br />

containing controller view and layout files<br />

containing layout view files<br />

containing view files for DefaultController<br />

the index view file<br />

A module must have a module class that extends from CWebModule. The class name is<br />

determined using the expression ucfirst($id).'Module', where $id refers to the module ID<br />

(or the module directory name). The module class serves as the central place for storing<br />

information shared among the module code. For example, we can use<br />

CWebModule::params to store module parameters, and use CWebModule::components to<br />

share application components at the module level.<br />

Tip: We can use the module generator in Gii to create the basic skeleton of a new<br />

module.<br />

Using Module<br />

To use a module, first place the module directory under modules of the application base<br />

directory. Then declare the module ID in the modules property of the application. For<br />

example, in order to use the above forum module, we can use the following application<br />

configuration:<br />

return array(<br />

......<br />

'modules'=>array('forum',...),<br />

......<br />

);<br />

A module can also be configured with initial property values. The usage is very similar to<br />

configuring application components. For example, the forum module may have a property<br />

named postPerPage in its module class which can be configured in the application<br />

configuration as follows:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!