Jan Eden <[EMAIL PROTECTED]> wrote:
:
: I have written a little script to update a bunch of HTML
: files. I know I could (maybe should) use a module such as
: HTML::Template, but my script worked fine until now.
:
: Each site updated with the script has a root directory
: and a template, which are determined according to a meta
: tag (type) in the HTML files:
:
: [snip]
:
: if ($page =~ m#<meta\s+name="type"\s+content="([^"]*)"?/?>#i) {
: $return_hash{type} = $1;
: }
:
: $site_root = '~/Sites/' . $site_type;
:
: $site_template = $site_root . '/templates/' . $site_type . '.tpl';
:
: So, for the site 'janeden', I get the site root
: '~/Sites/janeden' and the template location/name
: '~/Sites/janeden/templates/janeden.tpl'. The $site_root is
: essential to determine the relative links on each HTML page.
:
: But now I had to change the layout and embed some sites.
: Their site roots and template location are now
:
: '~/Sites/janeden/whatever' and
: '~/Sites/janeden/whatever/templates/whatever.tpl'
:
: I temporarily fixed the resulting problem by adding another
: meta tag (parent), which contains the name of the embedding
: site. But there has to be a smarter solution.
:
: Can someone give me a hint?
Assuming only one of the templates exist, test for the
existence of the usual template. If it does not exist use
the alternate template.
if ( -e $template_file ) {
$site_template = $site_root . $template_file;
} else {
$site_template = $site_root . $alternate_template_file;
}
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>