My legacy websites use an old CGI (perl) script that inserts a raw content
file inside a master template (aka the layout).
The way this worked is by way of url. The syntax would be :
domain.com/article.cgi?file=content.html
Where "content.html" would be inserted inside "template.html" (at an
insertion point called <!-- RAW --> somewhere on a blank line inside the
template file), then displayed to the user. There would be hundreds of
"content" files, but just 1 "template.html".
Since then, I've switched to PHP includes, and completely forgotten about
the old perl script. But as I'm dusting off my legacy websites and
bringing
them up to code, I realize that this old perl script holds two major
advantages over the PHP includes.
1. FEWER FILES ON THE SERVER. Since the url tells article.cgi what to
parse
with what, there's no need for a separate file telling the server what
pieces to combine with what. In PHP, you'd need the file with the includes
inside, AS WELL as the raw content file. For each instance of new content,
you'd also need a new "assembler" file containing all the includes. So if
you have 200 content files, you've got an additional 200 php files
containing all the necessary includes.
2. ABILITY TO EDIT TEMPLATE DIRECTLY IN DW. With PHP, you've got your
header
as one include, the content as another, and the footer as a third. If
you're
used to the design view, you can't edit the header or the footer any other
way than by re-combining them in a temp file and working on THAT... then
splitting them up again as header and footer files (the reason being that
most of the tags opened in the header aren't closed until you get to the
footer, so opening either one on its own will cause Dreamweaver to freak
out
and kick you in the balls as a reflex).
I was therefore wondering how difficult it would be to mimic the perl
behavior in PHP.
In other words, have a "template.html" file with an insertion point
specified via comment somewhere inside it, and have all files targeted by
the URL go there before the combined webpage is displayed to the user.
There
might even be a way to modify .htaccess so that every webpage on the site
is
included inside this "template.html" file before display.
How do-able is any of this? Depending on the level of complexity, I'd even
be willing to pay for the help.


|