Thread CSS Layout mit Perl (10 answers)
Opened by bieber at 2007-07-19 10:52

renee
 2007-07-19 11:13
#29069 #29069
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Mit einem Template und CPAN:HTML::Template::Compiled könnte es so aussehen:

Template:[html]<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
<head>
<title>Testtitel</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<link href="/style/test.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="content"><TMPL_VAR NAME=BODY></div>
<div class="menu">
<a href="?action=seite1">Seite1</a><br />
<a href="?action=seite2">Seite2</a>
</div>
</body>
</html>[/html]

Skript:
Code (perl): (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
#!/usr/bin/perl

use strict;
use warnings;
use CGI;
use HTML::Template::Compiled;

my $cgi = CGI->new();
print $cgi->header();

my %params = $cgi->Vars();
my $template = HTML::Template::Compiled->new( filename => 'htc_bieber.tmpl' );

if( !$params{action} or $params{action} eq 'seite1' ){
    seite1( $template );
}
elsif( $params{action} eq 'seite2' ){
    seite2( $template );
}
else{
    fehler( $template );
}

print $template->output;

#--
# Subroutines
#-- 

sub seite1{
    my ($tmpl) = @_;
    $tmpl->param( BODY => 'Testseite Nr. 1' );
}

sub seite2{
    my ($tmpl) = @_;
    $tmpl->param( BODY => 'Sie haben Seite Nr. 2 gew&auml;hlt' );
}

sub fehler{
    my ($tmpl) = @_;
    $tmpl->param( BODY => '&Auml;tsch! Seite existiert nicht' );
}


Das ist jetzt mal ganz einfach gehalten. Du findest unter http://renee-baecker.de/vortraege.html ein paar Unterlagen zu CPAN:HTML::Template. Die Sachen dort kannst Du fast 1:1 auf CPAN:HTML::Template::Compiled übertragen...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread CSS Layout mit Perl