[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
Re: wml::des::navbar: automatically selecting the right button
- From: nospam@thanx (Ralf S. Engelschall)
- Date: Thu, 8 Jan 1998 14:09:51 +0100 (MET)
Hello Oliver Hensel, in a previous mail you wrote:
> I currently have some question.
> I am using the great wml::des::navbar feature.
> I want to use a template, which automatically renders the navbar.
> That actually works, but I want to have the right button automatically selected
> by filename.
> I have no clue how to do that, does anyone of you??
Which button is rendered "selected" is set via the "select=ID" attribute of
<navrender>. Ok, here you have to choices:
1. You do it manually like me via a #use attribute.
My WML pages just do
| #use wml::tmpl:swpage area=XXX
and the tmpl/swpage.wml file contains
| <navbar select=$(area) [...]>
I personally have no problem with this.
2. You can do it automatically what you want, based
on the filesystem structure. Here the keys are the two variables
WML_SRC_DIRNAME and WML_SRC_FILENAME. The last one usually holds something
like "index.wml". What you now have to do is the following: Use these
filenames as the button id (<nb_button name=ID>!) and render your navbar
<navrender select=<get-var WML_SRC_FILENAME> [...]>
When you cannot do it such simple, i.e. need more difficult mapping between
WML_SRC_DIRNAME/WML_SRC_FILENAME to the ID, you have to use a trick:
| my $dir = '<get-var WML_SRC_DIRNAME>';
| my $file = '<get-var WML_SRC_FILENAME>';
| ...do some calculations here in Perl and
| store result into global Perl variabe $id...
| <navrender select="$id" [...]>
This approach can solve any problem of automatic selection because now you
have the complete power of Perl to do the calculation of the button to be
selected. When you are crazy you can even use Perl's DBI interface here to
resolve the button id from a database ;_)
Ralf S. Engelschall
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List email@example.com
Automated List Manager firstname.lastname@example.org