[Templates] stonehenge.com cutting over to Template from Mason
darren chamberlain
dlc@users.sourceforge.net
Tue, 5 Mar 2002 15:45:02 -0500
Quoting Randal L. Schwartz <merlyn@stonehenge.com> [Mar 05, 2002 15:06]:
> ...how best to represent and trigger the hierarchy of links for
> my top menu?
[-- snip --]
> What I'd like to do is find my place in the tree based on the
> URL, with some fallbacks if it doesn't exist, and then wander
> up the tree. I can't think of anyway to do this quickly with
> TT directives, so maybe I'm gonna have to go back to a plugin
> to hand the right data out. Am I missing something?
My first idea here is to use an XML representation of your
URI-space, and use XPath to access the elements, ech that you can
use the URL as the key with which you access the data. This is
probably more difficult than I'm thinking, but maybe something
like:
Your example:
> top = stonehenge merlyn
> stonehenge = home perltraining
> perltraining = home courses instructors prices (etc)
> merlyn = home cutestuff columns books
> columns = home wt ur lm
> ur = home 01 02 03 04 05 (etc)
> wt = home 01 02 03 04 05 (etc)
> lm = home 01 02 03 04 05 (etc)
<?xml version="1.0" ?>
<top>
<stonehenge>
<perltraining title="Perl Training">
<courses>
# stuff
</courses>
<instructors>
# stuff
</instructors>
<prices>
# stuff
</prices>
</perltraining>
</stonehenge>
<merlyn>
<cutestuff>
# stuff
</cutestuff>
<columns>
# stuff
# sections for 01 02 03 ...
</columns>
<books>
# stuff
</books>
</merlyn>
</top>
Accessing metadata can be a call like:
[% USE XML.XPath("site.metadata") %]
[% page_info = XML.XPath.find(request.uri) %]
And so on.
With a script that generates this XML file periodically, when you
add columns, and make other similar changes.
(darren)
--
I respect faith, but doubt is what gives you an education.
-- Wilson Mizner