Create a CMS
I have been contentedly using WebMake to build my site for years. It might be time to move on, though. There are a lot of features I want to incorporate into coolnamehere, and even though the content is fairly static some dynamic elements could enhance the experience for everybody.
So ... let's make a CMS!
I know, I know. There are tons of Content Management Systems out there. My problem is that they all seem like overkill for a site like coolnamehere. Besides, I need the practice putting a decent PHP application together.
What Am I Building?
Let's start by determining what I already have. Coolnamehere is an organized collection of effectively static articles. These articles are usually only changed as corrections or factual updates are needed. Every page on the site shares a common look and a "breadcrumb trail" that shows the page's relation to the main page of the site. There are also two site maps. The primary sitemap shows every page that is officially part of the site, and each page also has a mini sitemap in the margin which shows details like major sections of the site and other pages in the same section as the current page.
An important legacy detail to keep in mind is the fact that some of these pages have existed for years at the same URL, so we need to be certain that old bookmarks will still lead to the correct article.
I use a simple formatting system called Markdown while writing the articles, so I want that as well. I've actually used several formatting systems over the years, including Textile and EtText. I don't want so many formatting systems anymore and will probably need to rewrite those articles by hand.
What Will I Use to Build It?
The new version of coolnamehere will be stored in a MySQL 5 database to simplify the addition of new content in the future. I've become reluctant to add or change content over the years as my static files have steadily grown, because even a relatively small site like coolnamehere takes a while to build.
I'll use a templating system to enforce the common style of site pages. Smarty seems like a good choice. It is well-established and includes caching which may be helpful in the event of increased traffic.
PHP Markdown Extra will do nicely as a formatting system. It supports all of the Markdown I'm used to, along with a few extra features that make preparing articles even easier.
Oh, and this is all running on PHP 5.x. I'm not even vaguely interested in reliving PHP 4.
Should I use a MVC framework?
That is a really good question. I've been thinking about that, and ultimately decided that the overhead of learning the details of any given framework would cost time which I would rather spend in development. If this were a larger project with more developers involved, I would probably opt for a framework instead. I'll probably end up regretting it, but this is supposed to be a learning experience.
Starting With The Model
Well, it looks like MVC terminology is going to sneak in whether I like it or not. Articles are the single most important component of this application. They have three pieces:
Articles
- A unique ID number (since the URL may change)
- The title ("Untitled" by default)
- The content
- The article URL (unique, but can be changed)
- The time and date when the article was created
- The time and date when the article was last modified.
These articles exist within the context of a heirarchical site. I might be tempted to extract the heirarchy from the article URL, but that won't work for those redirect URLs I mentioned a moment ago. I'll store the heirarchy in another column instead.
So ... what does this table look like so far?
create database cnh_cms; use cnh_cms; create table articles ( id integer unsigned auto_increment, title varchar(100) default="untitled", content text, url varchar(255) unique not null, child_of integer unsigned, created_at datetime, modified_at datetime, primary key (id), foreign key (child_of) references articles(id) );
