Content Management System Software – Rolling My Own

content management system Every so often, at least once a year, I start working on a new content management system. Just as often, I give up on it for various reasons.

Not today! I finally had that “aha!” moment and realized the things I was doing wrong. I was trying to make a content management system for anyone when I only needed to make one for me. I also didn’t quite comprehend how certain CMS products use permalinks that don’t match the file system. I do now.

The WordPress Content Management System

Sure, WordPress started out as merely a blogging platform, but it has long since matured into a full-fledged CMS. At the heart of it, it’s still just a PHP script – a complicated and long PHP script.

The magic happens when you engage any public URL on a WordPress website. Using server rewrite rules (or redirects), files that don’t exist get sent to the index file in the root directory. With WordPress, none of those files exist.

The index file in WordPress starts the WordPress engine, which does a lot of stuff most people don’t even pay attention to until they need to change something. WordPress has tons of plugins and themes available and a lot of people working on it all the time.

Here’s how the index file gets called with Apache:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Those flags, !-f and !-d, look for a filename that’s either a file or a directory. When it doesn’t find it, it sends PHP to the index file.

Here’s how it gets called with Nginx:

try_files $uri $uri/ /index.php;

It does the same thing, only it’s a lot shorter. It’s one of the reasons I like Nginx more than Apache.

I’ve used WordPress since 2006, most recently as a static site generator on my laptop (while running Linux Mint). I can use some of it as a model for the CMS system I’ll be working on.

My Content Management System

It’s going to be a content management system and a static site generator. That’s what I’m doing with WordPress now.

There’s a lot within WordPress that I don’t need and I don’t need what some of the new CMS products expect. I don’t need an image library or an HTML editor.

Things like this get easy when you memorize most HTML tags and keep up with the HTML changes (like HTML5). There’s an easy way to get around not using responsive images – keep all images at 320 pixels wide or less and don’t link to a larger image.

I’m not a front-end web designer. That kind of stuff confuses me. Luckily, it’s pretty easy to convert any WordPress theme to a single HTML page (using the page source, of course). There are free templates and designs all over the web (like HTML5Up!) if I choose to use one of them instead of a WordPress theme.

I won’t be using a database. Plain text files, with certain delimiters before the content, will rule the day. The “file_get_contents”, “file” and “glob” functions can do most of the heavy lifting.

I’ll definitely be borrowing some routines from the WordPress content management system, like how WordPress processes post content (but only part of it). I’m not going to rely on a script to add or change HTML tags.

Rolling my own content management system is going to be fun. I don’t even need an administrative back-end to do what I want to do. Still, I might use one just to augment my lack of recall when doing certain things.

March 11, 2017

Web Development

Previous and Next Articles:

« »