[Templates] New user & question regarding two-pass processing / persistent data

Lars Marowsky-Bree lars@marowsky-bree.de
Sun, 12 Jan 2003 17:34:35 +0100


Good morning all,

I am (going to be, hopefully ;) a new user of the Template Toolkit; it looks
the closest to what I want and extensible enough to modify. I haven't done web
programming since 1995, so some of my ideas might be slightly outdated l-)

(However, I _do_ know how to write Perl, no worries ;)

My basic idea is - for a rather simple website which doesn't need truely
dynamic content - to have a source tree and build a (static) target tree from
that. That's simple enough to do, and right now the site is implemented using
SSI, so it isn't actually very complex.

However, I obviously want to go beyond what SSI could do. Namely, I want
things like menus to be generated automatically ("generate <ul> with all pages
which have 'foo' in their metadata") or site-internal links to be generated
automatically (so I can do [% MySite.Link("PageID") %] without worrying which
path the page actually is at, and also add a small language icon to links
based on the metadata of the target etc).

I want to build upon ttree to do my bidding, however, for the former I need a
way to store the metadata in files read persistently.

The simple approach would be to build a big hash with all metadata and dump at
the end / reread that at startup; this would be rather similar to how LaTeX
does things and would seem to be the simplest approach.

Now, I have some troubles getting into the Template Toolkit mindset; how do I
get the metadata stash at the end of each page processed, and how do I access
that from my own plugins (elegantly)?

Maybe someone has already written something like this. I am using the 2.08
release version.


Sincerely,
	lmb

-- 
"I'm extraordinarily patient provided I get my own way in the end."
        -- Margeret Thatcher