Tuesday, June 6, 2006

Cubson First Step Guide (2)

Make-project

At first, make the project in your XOOPS Cube. Type the following.

cubson> make-project myannounce

Myannounce directory is made in the module directory of your XOOPS Cube. Make-project doesn't add on extra files that is SQL file and icon. So install this module soon.

Create tables

The announcement module shows messages that administrators post. Therefore, it shall have the following data model:

  • ID
  • Created datetime
  • Modified datetime
  • Subject
  • Messsage

ID is numeric that is primary key and autoincrement. Next, Cubson handle unixtime as datatime. Of course, such style has some problems. But, in 2006, we can use it to record working time. Next, subject is varchar, and message is text.

Create '{XOOPS_DB_PREFIX}_myannounce_message' table as like the following. If your XOOPS_DB_PREFIX is xoops, create xoops_myannounce_message:



  • id int(10) not null default 0 autoincrement, primary key
  • create_unixtime int(10)
  • update_unixtime int(10)
  • subject varchar(255) not null
  • message varchar(255) not null

iviewcapture_date_05_06_2006_time_16_44_28

Cubson has the naming rule for tables. You have to add on XOOPS_DB_PREFIX and module name to entity name. Next, generate basic control code in the control panel side.

cubson> wizard -a message

List, view, edit and delete function are generated in the admin directory of myannounce module. But, you can't access to it from the side menu because the front controller of admin hasn't been modified yet.

See /modules/myannounce/admin/index.php. This is the front-controller of every modules. It works your simple framework through Action Frame feature. This controller calls the logic files (actions) by $action request. If $action isn't sent, it uses the default value. The default value is "Default" literal. You have to replace it with "MessageList". Ok, "/modules/admin/index.php" comes to equal "/modules/admin/index.php?action=MessageList".

Try to access the control panel again. Does it work?

No comments: