[Techtalk] Web site setup

Dan dan at cellectivity.com
Wed Apr 20 19:15:12 EST 2005

I have an interesting problem with web sites that I'd like your comments
on. Currently our web site is static and is maintained by a
non-programmer who knows just enough HTML to get by. Since all our web
pages have the same style (and not just CSS), we'd like to use PHP to
dynamically generate the top and bottom of each page.

The person who maintains our web site is intelligent but isn't a
programmer, so we want to make this as easy as possible for her. I'd
like to have each page look something like this:

$title = 'Foo';
$content = '
<p>The main content of the page goes here.</p>

That's quite feasible except that you would have to escape all the
single quotes in the HTML content, which would be a pain for big
documents. PHP supports here-documents but that's not great either,
because you'd have to escape dollar signs and backslashes. Perl may
allow here-documents that you don't have to escape, but Perl isn't a
great choice because we're not doing any heavy-duty processing. This is
such a simple problem but there doesn't seem to be an easy solution.

An alternative is to store the main content in a separate text file, but
we don't want "unfriendly URIs" (URIs where the page is specified after
a question mark, like http://example.com/site?page=foo/bar/baz) because
they're not processed as well e.g. by search engines. And using a script
as the root of the URI tree (such as
http://example.com/script.pl/virtual/path) means that we can't later
decide to put something in the path that the script doesn't process
(such as http://example.com/script.pl/process-form.cgi).

This problem is pretty open-ended so I thought it might help me to get
some advice - and I also thought that everyone else would enjoy thinking
about it.    :-)

   Presumably, we're all fully qualified computer nerds here,
   so we are allowed to use "access" as a verb. Be advised,
   however, that the practice in common usage drives
   English-language purists to scowling fidgets.
      - from Sybex's "Perl, CGI and JavaScript", p. 256

More information about the Techtalk mailing list