Flat-File CMS Documentation



This project is currently under development.

Flat-File CMS provides many features of more resource hungry CMS packages such as wordpress, joomla, etc.. Features include: URL Rewriting, SEO Friendly URLs, automatic 404, dynamic directory path creation, integrated Smarty template engine allowing powerful features to be added to index.php and available in all pages of your site. Other features that Smarty brings into this implementation are inclusion of header and footer template files to be included on every page and setting a custom page title for each page without duplicating the header. All of the files and methodology are completely open source and extensible.


Click Here to download Flat-File CMS now. File provided as .tar archive about 1MB in size.


SEO Friendly Links

Utilizing a virtual directory structure Flat-File CMS is able to present easy to remember, easy to type, and visually pleasing URLs to the end user. For the administrator making a file located at xodustech.com/articles/recipes is a simple as naming a file articles-recipes.tpl.

Extension Filtering

Upgrading an old site with existing URL's such as xodustech.com/articles/recipes.html is made easy as Flat-File CMS will automatically truncate or ignore anything after the period in the file name. This makes it possible to seamlessly transition to Flat-File CMS without invalidating hundreds or possibly thousands of links that may exist to your site.

Automatic 404

Instead of nasty server error messages that may expose sensitive information, Flat-File CMS provides an automatic feature to gracefully display a custom 404 (page not found) page that you may customize to your liking.



A webserver or local computer capable of rendering PHP files.


Flat-File CMS can be installed or run anywhere in your webserver's public_html or www directory. Simply extract the contents of the .tar archive and update the config options in index.php as detailed below.

Config Options

define('INSTALL_DIR', dirname(__FILE__).'/');
define('CONTENT_DIR', 'content');
define('WEB_DIR', '/');

The above block of code will autodetect the directory your index.php is installed. The CONTENT_DIR should be the directory where your templates are stored, WEB_DIR should be set to the path where your CMS is installed. If you are installing this to the public_html or www directory directly then leave this as '/', if you install this to a directory called cms your WEB_DIR would be '/cms/'.

$Smarty = new Smarty();

The above will include the Smarty class file and setup a new instance. Smarty comes pre-installed with Flat-File CMS so unless you change the name of the libs folder or move this you won't need to touch the above.

$Smarty->assign('APP_TITLE', 'Xodus Tech');
$Smarty->assign('template', INSTALL_DIR.CONTENT_DIR);
$Smarty->assign('rel_template', WEB_DIR.CONTENT_DIR);

The above sets up variables that will be passed to whichever page ends up being displayed. The APP_TITLE variable is used in the title of each page in combination with the data sent by the specific template, more on this below in the template examples. The template variable sets the server path where the template is located to be included, the rel_template variable contains the web path to where your template folder is and can be used when including javascript, css, images, etc so in the event you move your content directory nothing needs updating in the template itself.

Template Examples

All template files will reside in your content directory, Flat-File CMS comes with several templates setup by default to provide the basic functionality.



The above template code sets up the header and includes the title that is setup as a combination of APP_TITLE and the title sent with the individual template as shown below.


{include file="$template/header.tpl" title=$APP_TITLE|cat:" - Home"}
  <h2>Home Page</h2>
  <p>body text would go here<p>
{include file="$template/footer.tpl"}

Flat-File CMS will call this page when requesting the base domain or URL where Flat-File CMS is installed.


{include file="$template/header.tpl" title=$APP_TITLE|cat:" - Test Page"}
  <h2>Test Page</h2>
  <p>body text would go here<p>
{include file="$template/footer.tpl"}

The above template code includes the header, displays a short message and includes the footer. By naming this file test-page.tpl you are creating a virtual path to the file in your browser such as xodustech.com/test/page.


{include file="$template/header.tpl" title=$APP_TITLE|cat:" - Page Not Found"}
  <h2>Sorry, the requested page could not be found.</h2>
  <p>body text would go here<p>
{include file="$template/footer.tpl"}

Flat-File CMS will call this page in the event the URL you are requesting is either not a valid file or folder or a valid virtual path within Flat-File CMS (template files).



The above is self explanatory, this code gets included at the bottom of your template files making changes to your footer in the future a snap.

.htaccess explained

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

The .htaccess file does the magic of making sure the file or directory being requested does not physically exist and turns control over to index.php which will serve our templates. The first RewriteCond and RewriteRule automatically direct any non-www url to the www version which is helpful for SEO. The last section in the file detects if the file or folder exists and then directs to the Flat-File CMS index.php file.


Flat-File CMS was created by Travis Brown, email: WarriorRocker@gmail.com.