> Date: Thu, 25 Oct 2001 12:52:50 -0700
> To: [EMAIL PROTECTED]
> From: Bill Moseley <[EMAIL PROTECTED]>
> Subject: [Templates] Building menus with ttree

> Hi,

> Just to save me some time, are there any examples of building sidebar
> menus?  I'd like to generate a sidebar type menu where the current page's
> link expands to show a sub-menu for that page.  

> I will define a standard menu of first-level pages, but when those pages
> are visited have a sub-menu displayed for that page.  The small twist would
> be that I'd like to be able to automatically generate that sub-menu from,
> say, <h2> tags within that page (so people that don't know TT at all could
> still work with the content).

look around in the example page src provided with TT2.  You'll
probably find something there; i don't know my way around well enough
to tell you a short cut.

it would be hard (and time consuming) to provide specifics for what
you want to do.  but i can strongly urge you to use a data structure
to drive the generation of your pages and menus.

something like this nested key/value structure has served well in my
experience.

pages_struct = 
[
  [{'page1' 'Home page menu label'}
   [{'option1' 'option 1 label'} {'option2' 'option 2 label'} ...] ]
  [{'page2' 'Page two menu label'}
    [...] ]
]

you can express this in perl or tt syntax or define it in an
Apache-style configuration file such as the Config::General library
reads.

your TT2 code would need nested FOREACH loops to take apart the pages
structure and wrap HTML around the pieces.  you should key the file
names to the above page keys.  If you embed the page key into each
page, you can also gray out the current page's menu option when you're
already on that page.  Hope that makes sense.


-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
Richard Tietjen <[EMAIL PROTECTED]>        www.pobox.com/~rdtietjen
          "Irony is what they make two-edged swords from."
-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-



Reply via email to