Creating modules
If you have created a complex application part and want to use it with some degree of customization in your next project, most probably you need to create a module.
In this recipe we will see how to create a wiki module. For simplicity, we will not focus on the user and permissions management but will let everyone edit everything.
Getting ready
Create a fresh Yii application using
yiic webapp.Configure MySQL database and execute the following SQL:
CREATE TABLE `wiki` ( `id` varchar(255) NOT NULL, `text` text NOT NULL, PRIMARY KEY (`id`) )
Generate the
Wikimodel using Gii.Move
protected/models/Wiki.phptoprotected/modules/wiki/models/.Add
wikito themodulessection ofprotected/config/main.php:'modules'=>array( // uncomment the following to enable the Gii tool 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>false, ), 'wiki' ),
How to do it...
Let's do some planning first:
A wiki is a set of pages where one page can link to another...