|
-
Senior Member
CMS Tutorial
Okay, as a follow on from the last one, I decided to revisit the simple CMS system as I've been getting more and more enquiries about it and the files on that thread no longer exist.
I'm starting from scratch so you can ignore the previous CMS thread
I decided, I'm more likely to be interested in completing the project if it is something I will use so I have opted for creating something for one of my affiliate sites. In my example, the CMS is used for a casino and poker affiliate site but its uses stretch far beyond that.
Analysis
Okay, first of all, we ask ourselves why we need a CMS system. With the ability to edit files using a web control panel, I have enough knowledge to edit my site from any computer in the world with an Internet connection but this project is for someone else to create and publish content knowing only a small amount of HTML / Javascript etc. So the first thing I am going to do is plan the best way for this to work.
Design
I have decided that instead of doing a CMS system page by page, it would be useful to be able to reuse certain aspects of content. For example, if we take the following 3 pages and the components that make up the page:
Page 1 - All about 32 Red Casino
32 red casino review
32 red bonus scheme
32 red software
32 red promotions
Page 2 - Casino Bonuses
32 red bonus scheme *
Littlewoods casino bonus scheme
Intercasino bonus scheme
Page 3 - Casino Reviews
Littlewoods Review
Intercasino Review
32 Red casino review *
As can be seen by the pages flagged with the blue star, these 'paragraphs' occur more than once so instead of duplicating the data, I want to be able to have it sit in one place and be able for it to be displayed on more than one page.
Because of this, I decided that I wanted the data to be seperate components viewable by linking pieces together to form pages, therefore my first table would be these seperate components, hereby known as 'paragraphs'.
Part one - Paragraphs
The first table contains a unique identifier (primary key), a title and the content. To create this table, run the following SQL in your database:
Code:
CREATE TABLE `para` (
`paraId` int(11) NOT NULL auto_increment,
`paraTitle` varchar(100) default NULL,
`paraContent` blob,
PRIMARY KEY (`paraId`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;
then, I create a simple form which accepts a title and the content and use the following MYSQL code to insert the data into a table called 'para'.
Code:
$connection = mysql_connect($host, $user, $password) or die ("can't connect".mysql_error());
$db = mysql_select_db($database, $connection) or die ("can't connect to database");
$query = "INSERT INTO para (paraTitle, paraContent) VALUES ('$paraTitle', '$paraContent')";
mysql_query($query);// or die(mysql_error());
mysql_close();
I'll post the files for this shortly. Feel free to ask questions as we go along.
Last edited by RazoRmedia; 03-14-2005 at 06:04 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|