On 15 Apr 2004 at 17:56, Bill Moseley wrote:
> It's a perl statement.
This much I assumed.
>
> With TemplateDefault the (HTML) output is generated in Perl code. For
> example, there's a subroutine called "page_header()" that prints out the
> first part of the page -- part that's the same regardless of the search
> results.
>
> It does this (which I think you have modified):
>
> return <<EOF;
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>
> $html_title
> </title>
> </head>
> <body>
> <h2>
> $logo$title $message
> </h2>
> EOF
>
>
> where $html_title, $logo, $title, and $message are generated in perl code.
>
> So just modify it to meet your needs:
>
> # Fetch standard site menu
> my $menu = `cat /path/to/menu/file.txt`;
>
> return <<EOF;>
In my reliably unreliable coding, I forgot the space between the cat and the path
statement....works just fine, now!
>
> Or maybe place in a table if you don't want to use css for placement.
>
At last something I feel semi-literate in discussing(!): I only use tables for things that are
really tabular data. This is sort of the mantra of the CSS-infatuated, I know. But it really
makes a lot of sense, especially for those using screen readers, etc. Tables sure are
bulletproof, compared to layers, though...
>
> Now, I wouldn't normally use "cat" like above, but it was a one-line
> example. Maybe something like this:
>
> # Open file and abort on error
> open( FH, "<$menu_path" )
> or die "Failed to open menu file '$menu_path': $!";
>
> # Read in menu HTML
>
> local $/; # undefine input record separator
> my $menu = <FH>; # slurp in entire file;
> die "No menu loaded from file $menu_path"
> unless $menu;
>
>
> Which is kind of a pain. Which is why it's nice to use a templating
> language all that stuff is done for you and then you just say:
>
> <div class="site_menu">
> [% INCLUDE site_menu %]
> </div>
>
> For more examples look at the search.cgi example script that uses
> Template-Toolkit -- the template in the program is embedded right in the
> script after the __DATA__ mark in the file, but normally the template
> would be a separate file -- and every one of those BLOCK sections might
> also be in a separate file (or row of a table in a database).
>
> Not that I'm pushing Template-Toolkit.
>
I will be going over all of this when I get some spare time. Thanks so much for your
patience and help - I really had no hope of getting Swish-E running productively until I
joined this list!
Cheers --- Phil Matt
Received on Fri Apr 16 08:29:57 2004