Modular Website Setup
After making several iterations of my personal site, I've finally found a php backend solution that has made me happy. While I have no doubt that I'll find a new system or methodology within the year that will warrent a complete redesign, my current setup is surprisingly simple and fun to play with.
As php is my primary coding language, I make it a personal goal to never use third party plug-ins. I often utilize jQuery or posted Javascript plug-ins in my work, mostly because working with Javascript and forcing it to work in every available browser can be excrutiating. I have never used Ignitor or Wordpress for a project and do not see the need for it in my near future. So, when I create new sites and applications, I might find myself copying some of my old code for a particular function, but often try to make it cleaner or more efficient during the development process.
When I tackled my personal site this time around, I tried to sketch out the data flow before coding. Not only did I want a central file to handle all web page requests (mod rewrite style) and create the wire frame of my div layout, but I also took all of the unique content, including meta data and navbar, and put it in a separate file outside of my public_html folder. All of this is generated and sorted by functions called from the central file but parsed by the content file. My basic configuration is handled by the third, and final, script for my site and declares the important sql connection and variables.
This allows me to do some pretty nice things. While design is all locked away in a css document, the div layout is handled by my xhtml. If I decided to switch my sidebar with my content, for example, I'd have to move three lines of code in my xhtml. In fact, the central file (and only one publically accessible) is only 65 lines long (most of them for spacing purposes). To move divs and data around is extremely simple. The content file parses out what page is requested in each function and displays the appropriate information. For example, if you visit the blog page, different side modules are displayed then on the home page. All of this is parsed out and printed from a single script and a small set of functions.
The only problem I've found with this layout involves the page parser. I have a single function that parses out the requested page and, in turn, requests different functions and different information from each one. This first function is, at times, a bit tedious to work with and understand. However, playing with one or two lines of code rather then copy/pasting an entire block of several hundred lines is a bit of an upgrade.
I did explore some different options with this site, including xsl/xml and pure AJAX. However, this option was not only easiest to implement, as I have a pretty decent handle on PHP, but also the most reasonable for my needs. A future change may include purifying an OOP or MVC setup, but I haven't seen any need or advantage of doing so yet.
Comments (0)