Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Design vs. Code vs. Maintenance

by swiftone (Curate)
on May 17, 2000 at 23:07 UTC ( [id://12215]=note: print w/replies, xml ) Need Help??


in reply to Design vs. Code vs. Maintenance

Unlike the many HTML::Template and CGI::Fasttemplate followers, I designed a similar system using Text::Template. My site, however, involved only a few templates for many layers. (e.g. Home page, 2nd-level pages (any any deeper)). The goal was to separate the site into three parts: Content, for non-computer people to edit. TEmplates, for interface people to edit, and code, for programmers.

It works like this:

  • I have a database holding the info for all the pages (title, name, Keywords for meta tags, and parent-child relationships.) The database isn't vital to the concept, but lets us modify the site structure easily.
  • I have a small script that consists of two subroutines, one that loads all variables for a given page from the database, and another that uses Text::Template to load a given file. I use the prepend option of Text::Template to load that template with this very script (So my templates can in turn call templates, etc)
  • Actually, I have several variants on #2, each with a slightly different purpose. One writes an HTML file (or multiple files). One displays the content parsed into HTML, but without writing a static HTML file, another does the same thing, but wraps the text of the content in TEXTAREA fields so it can be edited, etc..
The result is two-fold. The goal of separation has occured, allowing us to quickly re-build and add onto parts of the site. Also, because there is a difference between the base content files and the actual "built" HTML files, we have an effective Staging Area for content to be reviewed and approved before going Live. Combining this last part with some simple RCS has given us a measure of control and version history as well. Also, we can simply point our build script at a different set of templates, and generate a sub-site that is (for example) for text-only. No need to duplicate content. In case you are curious, Content pages look like this:
<!!&SiteBuilder_Load($Header,$ID)!!> Uneditable content <!!$BeginText!!> Editable Content <!!$EndText!!> more uneditable content <!!&SiteBuilder_Load($Trailer, $ID)!!>
(<!! and !!> are the tags I choose for Text::Template)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://12215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-20 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found