On Sat, Jul 09, 2005 at 09:28:04PM +0100, Markus Winter wrote:
> and I already have the next question - I have a bit of text which has to be
> on several websites (but can't be in a frame). Is there a way to incorporate
> this into several websites while having to edit it only once (otherwise when
> changes have to be made I would need to change at least 10 websites)?

I suspect the best way to make this happen would be either

1) Server-Side Includes
or
2) a bit of Javascript included in each file.

The latter is, in my view, a hack that makes poor use of
Javascript, but clients of mine have used it and I've
grudingly admitted that it's probably the best they could do
under the circumstances. These clients used webhosts
that refused to let them use much server-side architecture
at all, so they've had to push all their templating out to
the client.

So the Javascript approach includes a standard file -- call
it /boilerplate.js -- that looks like so:

function boilerText() {
        document.writeln("This is the text that will appear everywhere.");
}

Then call boilerText() at some point.

The annoyance here is that you'll need to include
/boilerplate.js in every file you send out. The advantage is
that once you've included boilerplate.js, you can ignore the
files that include it and just edit boilerplate.js to make
changes across your site.

I'd prefer the SSI route, if it's available to you. SSI +
mod_rewrite is super-handy. In the .htaccess file for your
website, include something like this:

RewriteEngine On
RewriteRule ^(.*\.html) template.shtml?$1

Then let template.shtml look something like this:

        <!--#include virtual="header.html" -->
        <!--#include virtual="$QUERY_STRING" -->
        <!--#include virtual="footer.html" -->

Now every page will have a standard header and footer, with
the part between the header and footer depending on what the
user asked for: every request for

http://example.com/foo.html

will turn -- via mod_rewrite -- into a request for

http://example.com/template.shtml?foo.html

But users will never see that.

Sorry if I rambled on too long. Basically what you're
looking for is a template, and I think these are the
simplest approaches to getting server- or client-side
templating.

-- 
Stephen R. Laniel
[EMAIL PROTECTED]
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key

Attachment: signature.asc
Description: Digital signature

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to