PHP Templating

I’ve always wanted to create a CMS system using PHP. I currently have an opportunity through my work to develop a custom form webapp for one of our clients, which I’ve been working on non-stop for the past day or so.

I’ve got no idea how anyone else does templating, but I’ve devised my own little method to replace BBCode style tags embedded within HTML with little bits of code here and there. It really is nasty, but it does the job. At the moment, all it’s being used for is to create a form, which is dynamically updatable by our client so they can add new fields and new forms as required.

"; } elseif (preg_match("/\[label:(\w+)\]/",$replaceThis,$labelField)) { $labelField = $labelField[1]; $replacement = ""; } else { switch($fields[$fieldName]['type']): case 'text': $replacement = " "; break; case 'textarea': $replacement = ""; break; default: $replacement = " "; endswitch; } $templateHTML = preg_replace('/\['.$fieldName.'\]/',$replacement,$templateHTML); } echo $templateHTML; } else { ?> No form selected!

The template data is actually stored in the database as follows:

0 0 votes
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
%d bloggers like this: