[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: Nested navbars




In article <m1iuqfdd7s.fsf@foobar.ee.ethz.ch> you wrote:

> I was wondering, if (or better, how?) nesting of navbar's could be
> accomplished. For example:

> PAGE 1            PAGE 2

> Topic 1           Topic 1
> Topic 2           Topic 2
>   Subtopic 2a     Topic 3
>   Subtopic 2b       Subtopic 3a
>   Subtopic 2c       Subtopic 3b
> Topic 3             Subtopic 3c
> Topic 3             Subtopic 3d
> Topic 5           Topic 4
>           Topic 5

Hmmm... this a non-trivial requirement which needs a non-trivial solution. But
because WML can do anything we want ;-), after thinking deep enough about this
problem I now came to the conclusion that it is solveable and only solveable
in combination with the diversion mechanism (Pass 5). This is no restriction,
just a fact.

So, to make the statement short enough, here is the final working solution:

==================================
##
##  navbar2.inc -- support nested navbar with two levels
##  Copyright (c) 1998 Ralf S. Engelschall, All Rights Reserved. 
##

#   we are based on the original navbar tags
#use wml::des::navbar
#use wml::des::space

#   the container tag for definition of the
#   main navbar or a sub navbar
<define-container nb:define>
<ifeq "%0" "main" <prog
    <navbar:define name="main">
      <navbar:header>
        <table cellspacing=0 cellpadding=0 border=0>
        <<FILLER>>
      </navbar:header>
      <navbar:prolog>
        <tr><td><b>
      </navbar:prolog>
      %body
      <navbar:epilog type=S>
        </b>
        #   HERE IS THE NESTING!
        <<SNB>>
        </td></tr>
      </navbar:epilog>
      <navbar:epilog>
        </b></td></tr>
      </navbar:epilog>
      <navbar:footer>
        </table>
      </navbar:footer>
    </navbar:define>
> <prog
    <navbar:define name="%1">
      <navbar:header>
        <table cellspacing=0 cellpadding=0 border=0>
        <tr>
        <td>
        &nbsp;&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;&nbsp;
        </td>
        <td>
        <table cellspacing=0 cellpadding=0 border=0>
      </navbar:header>
      <navbar:prolog>
        <tr><td>
      </navbar:prolog>
      %body
      <navbar:epilog>
        </td></tr>
      </navbar:epilog>
      <navbar:footer>
        </table>
        </td>
        </tr>
        </table>
      </navbar:footer>
    </navbar:define>
>>
</define-container>

#   the filler has to be coded seperatly to avoid
#   pass conflicts (sorry)
..FILLER>><space width=200><<..

#   the tag for defining a particular button
<define-tag nb:button>
<navbar:button id="%0" txt="%1" url="%2">
</define-tag>

#   and finally the nested rendering
<define-tag nb:render>
<navbar:render name=main select=%0>
..SNB>>
<navbar:render name=%0 select=%1>
<<..
</define-tag>
==================================

Now the specialized pagetemplate which uses this include file:

==================================
##
##  Definition of our navigation bar structure
##

#include 'navbar2.inc'

<nb:define main>
<nb:button topic-1 "Topic 1" topic1.html>
<nb:button topic-2 "Topic 2" topic2.html>
<nb:button topic-3 "Topic 3" topic3.html>
<nb:button topic-4 "Topic 4" topic4.html>
<nb:button topic-5 "Topic 5" topic5.html>
</nb:define>

<nb:define sub topic-1>
<nb:button subtopic-1a "Topic 1a" topic1a.html>
<nb:button subtopic-1b "Topic 1b" topic1b.html>
</nb:define>

<nb:define sub topic-2>
<nb:button subtopic-2a "Topic 2a" topic2a.html>
<nb:button subtopic-2b "Topic 2b" topic2b.html>
<nb:button subtopic-2c "Topic 2c" topic2c.html>
</nb:define>

<nb:define sub topic-3>
<nb:button subtopic-3a "Topic 3a" topic3a.html>
<nb:button subtopic-3b "Topic 3b" topic3b.html>
<nb:button subtopic-3c "Topic 3c" topic3c.html>
<nb:button subtopic-3c "Topic 3d" topic3d.html>
</nb:define>

<nb:define sub topic-4>
<nb:button subtopic-4a "Topic 4a" topic4a.html>
<nb:button subtopic-4b "Topic 4b" topic4b.html>
</nb:define>

<nb:define sub topic-5>
<nb:button subtopic-5a "Topic 5a" topic5a.html>
<nb:button subtopic-5b "Topic 5b" topic5b.html>
</nb:define>

##
##  The page template itself
##

<page>

<nb:render $(area) $(subarea)>

<p
<hr>
<p>
==================================

And finally the two sample pages which expand to exactly what you have
requested:

==================================
#include 'pagetemplate.inc' area=topic-2 subarea=subtopic-2b

This is page 1
==================================

==================================
#include 'pagetemplate.inc' area=topic-3 subarea=subtopic-3b

This is page 2
==================================

Gretings,
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com