On Tue, 3 Dec 2002, Paul wrote:
> Home > SubSection1 > SubSection2 > CurrentPage
>
> Subsections are descriptive names for the current directory structure
> that a page resides in. The above "CurrentPage" might be
> /sub1/sub2/index.ttml relative to the docroot.
I once wrote a breadcrumb system for TT that worked like this.
The site had a master map that was written in xml
<page name="Home" url="/">
<page name="Subsection1" url="/sub1">
<page name="Subsection2" url="/sub1/sub2">
<page name="CurrentPage" url="index.ttml">
...
</page>
...
</page>
...
</page>
Where name is the name of the page and url is the url it should link to.
Note that pages don't have to be placed in any place special, there's no
automatic directory thing.
I then had something like this in my page
[% USE Breadcrumb() %]
[% crumbs = Breadcrumb.to("CurrentPage") %]
This would cause my plugin to run an xpath query on the xml looking
for the one with the name equal to "CurrentPage". It then would climb
up the tree gettinging each parent until it reached the root node. Thus
it would have a list of nodes. Not that this is not quick...
Each step of the way it recorded te name and url, and returned them at the
end.. I think my first attempt was to return a datastructure like
[ { name => ..., url => ... }, { name => ...., url => .... } ... ]
But later on as the module got more advanced I returned acutal objects
that could then be processed with a view. The outer list was a
Breadcrumb::List and the hashrefs were Breadcrumb::Crumb objects.
That code looked something like this:
[% VIEW myview %]
[% BLOCK Breadcrumb__List %]
[% FOREACH crumb = item.crumbs %]
[% view.present(crumb) %]
[% '>' IF !loop.last %]
[% END %]
[% END %]
[% BLOCK Breadcrumb__Crumb %]
<a href="[% item.url %]">[% item.name %]</item>
[% END %]
[% END %]
Of course the actual code to do this was lost a long time ago, and I'm
typing the above without testing it at 2am in the morning, so I wouldn't
put too much faith in the actual example, but you get the idea.
Hope this at least gives you food for thought.
Mark.
--
Mark Fowler
http://www.twoshortplanks.com/ The 2002 Perl Advent Calendar
[EMAIL PROTECTED] http://www.perladvent.org/2002/
a different perl module featured every day
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.ourshack.com/mailman/listinfo/templates