Thread Dynamische Navigation mit HTML::Template (22 answers)
Opened by tonewheel at 2007-05-01 13:11

bloonix
 2007-05-01 21:06
#28973 #28973
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hier der Link zum Anschauen

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;
use Template;
use CGI;

my $cgi  = new CGI;
my $navi = $cgi->param('navi') || 'else';

my $template = Template->new;
print "Content-Type: text/html\n\n";
$template->process(\*DATA, { navi => $navi, navis => [ 'main', 'foo', 'else' ] });

__END__
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>[% title %]</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="navi.cgi" method="POST">
<select name="navi" size="1">
[% FOREACH value = navis %]
  <option value="[% value %]" [% IF value == navi %] selected [% END %]>[% value %]</option>
[% END %]
</select>
<button type="submit">Submit</button>
</form>
<ul>
[% IF navi == 'main'%]
  <li>main foo</li>
  <li>main bar</li>
  <li>main baz</li>
[% ELSIF navi ==  'foo' %]
  <li>foo foo</li>
  <li>foo bar</li>
  <li>foo baz</li>
[% ELSE %]
  <li>else foo</li>
  <li>else bar</li>
  <li>else baz</li>
[% END %]
</ul>
</body>
</html>
\n\n

<!--EDIT|opi|1178039714-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Dynamische Navigation mit HTML::Template