I don't know if this will solve your problem but I figured I'd harp in...
I wrote a CMS that allows for 3 nested templates.
At least you won't have to RECODE for every layout change...you just make a new template for the record. The script does the rest. Another kewl thing I did was set it up so you could pull templates from local AND remote sources (for branding) although I haven't used it for branding yet. :-)
Page (Site Identity page)
Table (Table details and navigation)
Record (field display)
RECORDs nests to TABLE nests to PAGE.
Each template is its own html file with keyword tokens within. The tokens are replaced with the content that is in the database / dir (depending on the call).
If your layout ever changes, you simply create a html page with the new layout and update the html links to use the new template (or you can use the ini option and make the new template the default). The templates can be as fancy or as plain as you want.
PLAIN (copy link into browser address bar)
http://programming.shrum.net/mysqlcms.php?dir=/scripts&table=http://www.shrum.net/generic_table.shtml&record=http://www.shrum.net/dir_record_row.shtml&where=`type`='dir'&from=`flying_sites`&cols=1&limit=0,1000&icon=script&title=Scripts%20and%20Modules&order=`name`&sort=asc
FANCY (not all that fancy but with images):
http://soaring.shrum.net/mysqlcms.php?rowcolor2=ffffff
You can take a look at the script I wrote (sort of a work in progress but I've been using it for my site for the last year or so). Use it if you want or at least get some ideas from it.
Documentation is limited to code comments right now but I'll get around to documenting the various things later.
GOTO:
http://programming.shrum.net - Scripts - mysqlcms.php > mysqlcms.php.txt (for source)
The folder will have a couple of files that show you what a typical template will look like. Take a look at the shtml files in that folder for ideas.
If you have any questions feel free to ask.