- HTML Admin-Manual
- PDF Admin-Manual
- HTML ITSM-Manual
- PDF ITSM-Manual
- HTML Developer-Manual
- PDF Developer-Manual
- HTML Developer-API
Table of Contents
The .dtl files are to 70% plain html and just used from frontend modules (Kernel/Modules/*.pm). The .dtl files are located under:
$OTRS_HOME/Kernel/Output/HTML/Standard/*.dtl
The usable dtl tags and syntax are described below.
TAB: We use two spaces for every new open tag. Examples:
<table>
<tr>
<td>Key</td>
<td>Value</td>
</tr>
<tr>
<td>aaa</td>
<td>bbb</td>
</tr>
</table>
<form action ="index.pl">
<input type="text" value="">
<input type="text" value="">
<table>
<tr>
<td>Key1</td>
<td>Value1</td>
</tr>
<tr>
<td>Key2</td>
<td>Value2</td>
</tr>
</table>
<input type="submit">
</form>
The dtl comment starts with a # at the beginning of a line and will not be shown in the html output.
# this can be a comment in the dtl file
If data params are given to the templates, these params can be printed to the template.
The name of the author is $Data{"Name"}.
Warning
If the value of the param Name includes html tags, these tags are also shown.
The same as $Data{""} but the value if the param Name is html quoted (safe).
The name of the author is $QData{"Name"}.
It's also possible to cut the value. If, for example, you just want to show 20 characters of a variable (result will be "SomeName[..]"), use the following:
The first 20 characters of the author's name: $QData{"Name","20"}.
The same as $QData{""} but with link encoding. This means for example that a space will be a + (e. g. for "a href").
<a href="$Env{"Baselink"}&Location=$LQData{"File"}">$QData{"File","110"}</a>
Env is an environment variable which is usable in more templates at a time. $Data{""} is just availabe for one template.
The current user name is: $Env{"Userfirstname"}
Some other common variables are:
$Env{"SessionID"} --> the current session id
$Env{"Time"} --> the current time e. g. Thu Dec 27 16:00:55 2001
$Env{"CGIHandle"} --> the current CGI handle e. g. index.pl
$Env{"UserCharset"} --> the current site charset e. g. iso-8859-1
$Env{"Baselink"} --> the baselink --> index.pl?SessionID=...
$Env{"UserFirstname"} --> e. g. Dirk $Env{"UserFirstname"}
$Env{"UserLogin"} --> e. g. mgg@x11.org
$Env{"UserIsGroup[users]"} = Yes --> user groups (useful for own links)
$Env{"UserIsGroup[admin]"} = Yes $Env{"Action"} --> the current action
QEnv is an html quoted environment variable (like Env but quoted).
The current user name is: $QEnv{"Userfirstname"}
A tag to quote html strings.
Show no html tags, quote this: $Quote{"<hr><b>some text</b></hr>"}
It's also possible to cut the value. If, for example, you just want to show 20 characters of a variable (result will be "SomeMess[..]"), use the following:
Show no html tags, quote this and show just 20 characters:
$Quote{"<hr><b>some text</b></hr>","20"}
This tag translates the string (based on the user selected language).
Translate this text: $Text{"Help"}
With this tag you can use config variables in the template. For example the Kernel/config.pm:
[Kernel/Config.pm]
# FQDN
# (Full qualified domain name of your system.)
$Self->{FQDN} = 'otrs.example.com';
# AdminEmail
# (Email of the system admin.)
$Self->{AdminEmail} = 'admin@example.com';
[...]
And the use in the dtl template:
The hostname is '$Config{"FQDN"}'
The admin email address is '$Config{"AdminEmail"}'
If you want to include other dtl templates into a template, use the include tag:
# include Copyright.dtl
$Include{"Copyright"}
Yet another examlpe:
<html>
<head>
<tilte>Some Title</tilte>
# include css.dtl file
$Include{"css"}
</head>
The block tag can be used to define blocks. These blocks can be used several times by the frontend module with different data params.
<table>
<!-- dtl:block:Row -->
<tr>
<td valign="top" width="15%">
<b>
$Text{"$Data{"Key"}"}:
</b>
</td>
<td width="85%">
<div title="$QData{"Value"}">
$QData{"Value","160"}
</div>
</td>
</tr>
<!-- dtl:block:Row -->
</table>
The html code can be displayed in template blocks in the frontend:
# get article
my %Article = $Self->{TicketObject}->ArticleGet(
ArticleID => $ArticleID,
);
# file blocks
foreach (qw(From To Cc Subject)) {
if ($Article{$_}) {
$Self->{LayoutObject}->Block(
Name => 'Row',
Data => {
Key => $_,
Value => $Article{$_},
},
);
}
}
# process template
my $HTMLOutput = $Self->{LayoutObject}->Output(
TemplateFile => 'AgentZoomBody',
Data => {
%Article
},
);
It's also possible to use a really "simple" (ne|eq|=~|!~) if condition.
<dtl if ($Text{"Lock"} eq "Lock") { $Data{"Language"} = "en"; }>
Or with a regexp.
<dtl if ($Text{"Lock"} =~ "/text/i") { $Data{"Lala"} = "Matched"; }>
This template function can still be found in several OTRS templates but will be removed in future versions of OTRS. The removal is necessary as a sequence control in the templates is not desired. The function should thus not be used any more.
If you want the output of a system call back to a dtl variable.
# execute system call
<dtl system-call $Data{"uptime"} = "uptime">
# print
The output of 'uptime' is: $Data{"uptime"}
Yet another example:
# execute system call
<dtl system-call $Data{"procinfo"} = "procinfo | head -n1 ">
# print
The output of 'procinfo' is: $Data{"procinfo"}
Usable to set: $Data{""}, $Env{""} and $Config{""}.