Describe Album Module
- The application that we are going to build is a simple inventory system
to display which albums we own. The main page will list our collection
and allow us to add, edit and delete CDs.
Page Description
List of albums
This will display the list of albums and provide links to edit and delete them.
Also, a link to enable adding new albums will be provided.
Add new album This page will provide a form for adding a new album.
Edit album This page will provide a form for editing an album.
Delete album This page will confirm that we want to delete an album and then delete it.
Slide 25
Slide 25 text
Create directories
- Creating following directories.
Slide 26
Slide 26 text
Create Module.php
- Create 'Module.php' in the Album module.
Slide 27
Slide 27 text
Configuration
- Create a file 'module.config.php' under \zendcms\module\Album\config
Slide 28
Slide 28 text
Config application.config
- Go to: \zendcms\config
- Edit file: 'application.config.php'
Slide 29
Slide 29 text
Routing and controllers
- As we have four pages that all apply to albums, we will group them in
a single controller AlbumController within our Album module as four
actions
Page Controller Action
Home AlbumController index
Add new album AlbumController add
Edit album AlbumController edit
Delete album AlbumController delete
Slide 30
Slide 30 text
Add Router
- Modify 'module.
config.php' under
\zendcms\modul
e\Album\config
Slide 31
Slide 31 text
Create the Controller
- Create controller class 'AlbumController.php' under \module\Album\src\Album\Controller
Slide 32
Slide 32 text
DB Schema
- Create SQL statements to create the album table.
Slide 33
Slide 33 text
Create the Model
- Create model class 'Album.php' under \module\Album\src\Album\Model
Slide 34
Slide 34 text
Create the Model Table
- Create model class
'AlbumTable.php' under
\module\Album\src\Albu
m\Model
Slide 35
Slide 35 text
Using ServiceManager to configure the
table gateway and inject into the
AlbumTable
- Create 'Module.php'
in the Album module.
Slide 36
Slide 36 text
Config DB Driver
- Modify 'global.php' under \config\autoload
Slide 37
Slide 37 text
Config DB Credentials
- Modify 'local.php' under \config\autoload
Slide 38
Slide 38 text
Create the View
- Create view 'index.phtml' under \module\Album\view\album\album
Slide 39
Slide 39 text
Open Album
- Go to: http://zendcms.com/album
Slide 40
Slide 40 text
Forms and Actions - Add album - Form
- Create view 'AlbumForm.php' under
\module\Album\src\Album\Form
Slide 41
Slide 41 text
Forms and Actions - Add album - Model
- Modify model class 'Album.php'
under \module\Album\src\Album\M
odel
Slide 42
Slide 42 text
Forms and Actions - Add album - Controller
- Modify controller class 'AlbumController.php' under \module\Album\src\Album\Controller
Slide 43
Slide 43 text
Forms and Actions - Add album - View
- Create view 'add.phtml' under \module\Album\view\album\album
Slide 44
Slide 44 text
Forms and Actions - Add album - Open
- Go to: http://zendcms.com/album/add
Slide 45
Slide 45 text
Forms and Actions - Edit album - Controller
- Modify controller class
'AlbumController.php' under
\module\Album\src\Album\C
ontroller
Slide 46
Slide 46 text
Forms and Actions - Edit album - Model
- Modify model class 'Album.php' under \module\Album\src\Album\Model
Slide 47
Slide 47 text
Forms and Actions - Edit album - View
- Create view 'edit.phtml' under \module\Album\view\album\album
Slide 48
Slide 48 text
Forms and Actions - Delete album - Controller
- Modify controller class
'AlbumController.php' under
\module\Album\src\Album\C
ontroller
Slide 49
Slide 49 text
Forms and Actions - Edit album - View
- Create view 'delete.phtml' under \module\Album\view\album\album
1) User (u)
CREATE TABLE `user` (
`uId` INT NOT NULL AUTO_INCREMENT ,
`uName` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT
NULL ,
`uPass` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
,
`uEmail` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
,
`uDesc` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
,
PRIMARY KEY ( `uId` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci
Slide 59
Slide 59 text
2) Tag (t)
CREATE TABLE `tag` (
`tId` INT NOT NULL AUTO_INCREMENT ,
`tName` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`tDesc` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY ( `tId` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci
Slide 60
Slide 60 text
3) Post (p)
CREATE TABLE `post` (
`pId` INT NOT NULL AUTO_INCREMENT ,
`uId` INT NOT NULL ,
`pTitle` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`pContent` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY ( `pId` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci
Slide 61
Slide 61 text
4) Meta (m)
CREATE TABLE `meta` (
`mId` INT NOT NULL AUTO_INCREMENT ,
`pId` INT NOT NULL ,
`mKey` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`mValue` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
PRIMARY KEY ( `mId` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci
Slide 62
Slide 62 text
5) Option (o)
CREATE TABLE `option` (
`oId` INT NOT NULL AUTO_INCREMENT ,
`oKey` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`oValue` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
PRIMARY KEY ( `oId` )
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci