in reply to Avoiding links to current page with HTML::Template
<TMPL_LOOP NAME="links"> <TMPL_IF NAME="linked"> <a href="<TMPL_VAR NAME="link_url">"> <TMPL_VAR NAME="link_text"></a> <TMPL_ELSE> <TMPL_VAR NAME="link_text"> </TMPL_IF> </TMPL_LOOP>
Then I can build an array for the loop, using something like this: (untested)
my $CUR_MODE = ## (the current mode) my %modes => ('mode9 => 'Customer Search', 'mode11' => 'Kit Search'); my @menu; for(keys %modes) { push @menu, { link_url => 'http://foo.com/?' . $_, link_text => $modes{$_} $_ eq $CUR_MODE ? (linked => 0) : (linked => 1) }
That will check to see which menu item corresponds to the current mode and decide whether to link it on-the-fly. You can wrap that in a function and use it in every mode, and pass the result to your template.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Avoiding links to current page with HTML::Template
by davis (Vicar) on Jul 15, 2004 at 18:10 UTC |