Lesson 29
Turn the Case Study into a Content Management System
In this lesson you add the ability to create additional pages of information for the Case Study site. These could be news articles, a page listing the privacy policy, or a blog article. Instead of creating a new .php content file for each one, you create a single .php file that displays page text that you have in the database.
Designing and Creating the Table
The first step is to create the table that will contain the page data. What is the information you need in this file? There is the obvious information such as
- Title
- Text
and other information you might want to keep:
- User who created the article
- Date article was created
- User who last modified the article
- Last date the article was modified
You also need a primary key so that you can select which article you want to display. Remember that the primary key cannot change and should be unique. Therefore you do not want to use the title as the key. Use an auto-increment integer key as you have in the other file.
This example is for a freeform page, but depending on your application, you could add additional fields that you could then place in particular places on the page. For instance, if you want all the articles to start with a picture and a short introduction and be followed by a list of references, you could add fields for each of those in your table.
You might also want to put your articles into different categories the way that the lots are in the Case Study. ...