Professional CodeIgniter

(singke) #1

Chapter 8: Last-Minute Upgrades


237


Creating a Page Manager


Now that you understand Claudia ’ s need for some simple page management (and to be clear, all she
needs is a simple way to create and edit just a handful of pages), you can get started on the work. When
creating a page manager, you need to keep several things in mind before you even start working.


  1. You ’ re not trying to build a full - on content management system. There ’ s no need to get wrapped
    up in issues like workflow, privileges, and other advanced criteria.

  2. You want to have an easy way to allow for WYSIWYG creation of HTML content. You ’ ll likely
    be integrating some kind of online editor like TinyMCE or Xinha.

  3. Don ’ t forget that at some point you also need to integrate with the Welcome controller and the
    public pages.


You will need to take this in stages. First comes the database table (which will hold all the data involved
with individual pages), then the model, then the controller, then the admin pages (the views that users
actually interact with), then integrating the WYSIWYG editor, and finally, making it work with the
Welcome controller.

Creating the Database Table


First things first, and that means creating the database table. In true Agile form, take the most
straightforward path and create a table called Pages. The Pages table should have a primary field called
id (which is de rigueur), and fields for a page name/title, keywords, description, status, the page
content, and a short path.

Of all of these fields, the path is the least transparent at this point, but its value will become clear to you
as you go. Basically, what you want is to be able to extract a page that matches a certain path. You ’ ll be
using the path as a “ unique identifier ” on the Welcome controller that will allow you to pull out the right
data. For example, if you want to pull out the About page, you want to match that path.

To get you started, here is a quick CREATE TABLE SQL statement.

CREATE TABLE IF NOT EXISTS ‘pages’ (
‘id’ int(11) NOT NULL auto_increment,
‘name’ varchar(255) NOT NULL default ‘’,
‘keywords’ varchar(255) NOT NULL default ‘’,
‘description’ varchar(255) NOT NULL default ‘’,
‘path’ varchar(255) NOT NULL default ‘’,
‘content’ text NOT NULL,
‘status’ enum(‘active’,’inactive’) NOT NULL default ‘active’,
PRIMARY KEY (‘id’)
) ENGINE=MyISAM;
Free download pdf