Webdesign chapter nine: CMS part 1

CMS stands for content management system, and is what quite a few websites use to manage their content. The content of the whole website is stored in a database and tools are used to store data or display data. Which means that the php files on the webserver don’t even have content anymore, they’re just used to get the content from the database and send it to the browser.

What I’m going to do now is write my own CMS. Now I obviously won’t go so far as to include all the functions that any of the open source CMS have, I will just write a very basic CMS that is more of a proof of concept than something that actually should be used. I will, however, be using it to display my homepage at xyious.com. The CMS I will write will be so basic that it could be explained in a single blog post, it will be tiny compared to what’s out there for free (list here). Don’t try to go through that whole list and check out every single one of them, though. A few commonly used ones are Drupal,ImpressJoomla!Typo3 and WordPress. If you want to use a CMS, have a look at those first, see how they work, see if they do what you want them to do, and after all that, if you need something different, you can still have a look at other alternatives (or write your own !!! ;).

I will use MySQL as my database, since it’s the only one offered by my hosting provider. I would prefer using PostgreSQL, since there are no licensing issues at all, among other advantages.

A database is a glorified spreadsheet (please don’t send me hate mail, I do know that’s not quite true), you have rows and columns that you store data in (in 99% of all databases) and you have functions to get the data back out. Every column has a name or identifier that you can (or have to) use to get your data.

We’re gonna make a new table in our MySQL database like this:

CREATE TABLE `xyious_content` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Timestamp` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL ,
`Author` VARCHAR( 255 ) NOT NULL ,
`URL` VARCHAR( 255 ) NOT NULL ,
`Tags` VARCHAR( 255 ) NOT NULL ,
`Headline` VARCHAR( 255 ) NOT NULL ,
`Description` VARCHAR( 255 ) NOT NULL ,
`Content` TEXT NOT NULL ,
PRIMARY KEY ( `ID` )
);

 

Create table obviously is the command to create a table (shocking i know), xyious_content is the name of the table we create, then on every line we have a column that we create. ID is the name of the first column, INT is the datatype, in the unsigned variety, not null means that we can never put “NULL” into this column and auto_increment means that we don’t need to actually put a value into this column, if no value is provided the last automatically entered value is incremented by one and that value will be used. The other datatypes we use are Timestamp, which saves a point in time (if no value is given the current date and time will be used), Varchar which means that a string of characters can be entered between 0 and 255 chars long, and Text which is a variable length text type that holds really long texts if it needs to. Primary Key means that we can reference any row by this column, which means that it has to be a unique value. I hope I didn’t add to the confusion with that paragraph. Please check the documentation of your database if anything is unclear.

Leave a Reply