Fishysplash-CMS. A Micro PHP CMS
Fishysplash-CMS is a micro content management system built in PHP. It is extremely small (<30K of php code in total), yet it contains several features found in larger CMS systems.
Unlike other 'micro' CMS systems that require plugins to do anything useful, Fishysplash-CMS has the following features out of the box:
The metadata for each article is stored together with the content in each file. The following metadata is maintained for each article:
The models folder contains the core domain logic. Central to these is the site.php class. This is class handles the basic IO for the web site, retrieving articles and comments from the file system. It also contains all the configuration details. Each controller has a reference to the site class to perform any updates.
The views folder contains the views for the application. These are simply files containing markup for the presentation. Each view is a template that is converted into actual HTML during the processing of the controller. The controller base class has a view() method that renders a view, merging with an optional 'model' array containing view data.
The controllers folder contains the controllers. Each controller is responsible for handling a particular URL or URL pattern. The controller generally complete processing by echoing a view as the response.
www.fishysplash.com/cms/cms.php?q=Linq/4
www.fishysplash.com/cms/cms.php?q=about-me
the 'q' query string parameter is passed to each controller. Each controller implements a 'get_route_pattern()' method which tells the framework what url(s) it can handle. The framework tries to match the actual parameter with this. The first controller that matches the incoming request parameter gets to handle the request. The request is then handled in the execute() method.
RewriteRule ^(.*)$ cms/cms.php?q=$1 [L,QSA]
This will result in the url being changed to the format required by fishysplash cms.
Unlike other 'micro' CMS systems that require plugins to do anything useful, Fishysplash-CMS has the following features out of the box:
- Written in PHP
- Articles are file-based. No need for My-SQL
- Allows feedback/comments
- Basic spam filtering by default
- Administrator login area, with content management abilities (e.g. edit articles).
- RSS feeds
- Ability to add tags for articles. These can be used to drive navigation menus
- Administration uses jHtmlArea JQuery plugin for proper HTML editing
- Provides clean urls
- Based on MVC pattern - HTML markup is separate to PHP files!
- Views are easily skinnable as they are not in the PHP code
- Articles and comments are indexed for fast processing
- Includes unique method of including code or 'snippets' in articles
Articles
Articles are the building blocks of the web site. Content can be added by the user using the special administrator login section. Articles are stored in a special folder, in text files, rather than in a My-SQL database. This keeps things simple, and allows for easy backup of the entire web site.The metadata for each article is stored together with the content in each file. The following metadata is maintained for each article:
- filename: the filename (excluding the extension) is used as the url for the article
- title: The title of the article. The text displayed on the banner for the article
- created_ts: the date that the article was created
- modified_ts: the date that the article was last updated
- is_published: 0/1 indicator specifying whether the article has been published. Only authenticated (administrators) users can view non published articles.
- allow_comments: 0/1 indicator specifying whether members of the public can add comments to the article.
Comments
Comments are each stored in a separate file, in a separate directory to articles. Each comment has the following metadata in addition to the actual comment:- title: the reference to the main article title
- name: the name of the person making the comment
- url: the url of the person making the comment
- email: the email of the person making the comment
- created_ts: the date that the comment was posted
Configuration
All the configuration is contained within the 'site' model class (site.php). The following items can be configured:- site_title: the title for the web site (user should change this)
- site_slogan: a slogan for the web site
- views_directory: the directory where the view templates are stored (default = "./views/")
- views_extension: the extension for view files (default = "vw")
- article_directory: the directory where articles are stored (default = "./articles/")
- article_extension: the extension for article files (default = "txt")
- article_index_file: the name of the file used as the article index (default = '_articles.idx')
- article_tag_index_file: the name of the file used as the article tag index (default = '_tags.idx')
- comment_directory: the directory where the comments are stored (default = "./comments/")
- comment_extension: the extension for comment files (default = "cmt")
- comment_index_file: the name of the file used as the comment index (default = '_comments.idx')
- comment_period: the period (in days) in which comments can be posted (defaul = 90)
- page_size: the number of articles to display per page when in index mode (default = 10)
- article_header_rows: this is an internal setting and should be left at '6'
- new_line: an internal setting. Leave as "\n" unless running on a non-Linux server
- md5_pwd: This is the hashed value of the administrator password. This should be set on a new installation.
Administration
A full administration area is available for the owner of the web site to create and maintain their content:
Design
Fishysplash CMS has been designed around a simple MVC pattern. The models, views and controllers are separated physically. Each can be easily configured to extend the system.The models folder contains the core domain logic. Central to these is the site.php class. This is class handles the basic IO for the web site, retrieving articles and comments from the file system. It also contains all the configuration details. Each controller has a reference to the site class to perform any updates.
The views folder contains the views for the application. These are simply files containing markup for the presentation. Each view is a template that is converted into actual HTML during the processing of the controller. The controller base class has a view() method that renders a view, merging with an optional 'model' array containing view data.
The controllers folder contains the controllers. Each controller is responsible for handling a particular URL or URL pattern. The controller generally complete processing by echoing a view as the response.
Page Request
Each request within Fishysplash goes through a simple set of steps in order for the final output to be rendered. Essentially, each controller is responsible for a single url or url pattern. The entry point to the CMS system is the cms.php module. The parameters for the request are always included in a query string 'q', for example:www.fishysplash.com/cms/cms.php?q=Linq/4
www.fishysplash.com/cms/cms.php?q=about-me
the 'q' query string parameter is passed to each controller. Each controller implements a 'get_route_pattern()' method which tells the framework what url(s) it can handle. The framework tries to match the actual parameter with this. The first controller that matches the incoming request parameter gets to handle the request. The request is then handled in the execute() method.
Clean URLS
My web site uses clean urls. This is easy do do using Apache' mod rewrite. simply edit the htaccess file, and add a line as follows:RewriteRule ^(.*)$ cms/cms.php?q=$1 [L,QSA]
This will result in the url being changed to the format required by fishysplash cms.
Installation
Installation simply requires copying all the files into your web site, modifying the site.php parameters, and modifying the htaccess file appropriately.Customisation
Being built around an MVC pattern, it is easy to extend this cms system. For example, I haven't implemented any month by month filter (for example, may web sites allow you to search on articles by month). However, it would be very simple for the reader to implement such functionality. Simply create a new controller, say called month_controller, than inherits from root_controller. Modify the filter method to filter by year and month (year and month would need to be provided in the url), and that's about it.Source Code
All the source code for fishysplash cms can be obtained here.David Barone, 12 February, 2010, 10:26 pm
Last Modified: 6 April, 2010, 7:31 pm

Comments: