RT 4.0.24 Documentation

This version has reached its end of life and is out of support. Please contact us for upgrade assistance.

Customizing/Templates

Go to latest version →

Templates

Each template is split into two sections. A block of headers and a body. These sections are separated by a blank line.

Templates are processed by the Text::Template module. This module allows you to embed arbitrary Perl code into your templates. Text wrapped in curly braces, {...} is interpreted as Perl. See Text::Template for more information.

Headers

Your template may specify arbitrary email headers. Each header is a name, a colon, then a value. So, for example, to specify a subject, you can use:

    Subject: Thanks for your bug report.

Special Headers

Content-Type: text/html

The special header "Content-Type: text/html" tells RT that the template should be parsed as HTML. RT will automatically make the outgoing message multipart. That way, recipients who can read only plaintext email will receive something readable, while users with clients which can display HTML will receive the full experience. Please be aware that HTML support in mail clients varies greatly, much more so than different web browsers.

We welcome contributions of HTML-ization of builtin templates.

Template Types

Templates have a Type which dictates which level of code execution is allowed.

Templates of type Perl are evaluated using Text::Template which allows arbitrary code execution. Only users which have the global ExecuteCode privilege may write templates of type Perl. Prior to RT 4.0, this was the only type of Template available.

Templates of type Simple permit only simple variable interpolation. No special privilege beyond ModifyTemplate is needed to write Simple templates.

For both types of templates, text between curly braces { ... } is interpolated. For Perl templates, this text can be any code (see "Details" in Text::Template). For Simple templates, only simple variables are permitted; for example { $TicketSubject }.

Variables

Perl templates

The variables that your templates may use include:

$Transaction

The transaction object.

$rtname

The value of the "rtname" config variable.

$Ticket

The ticket object. This is only set during a ticket transaction.

$Requestor

This is not an object, but the name of the first requestor on the ticket. If this is not what you need, inspect $Ticket->Requestors.

loc("text")

A localization function. See Locale::Maketext.

Selected Simple template variables

Since method calls are not allowed in simple templates, many common method results have been placed into scalar variables for the template's use. Among them:

$TicketId
$TicketSubject
$TicketStatus
$TicketQueueName
$TicketOwnerName
$TicketOwnerEmailAddress
$TicketCF(Name)

For example, $TicketCFDepartment.

$TransactionType
$TransactionField
$TransactionOldValue
$TransactionNewValue
$TransactionData
$TransactionContent
$TransactionDescription
$TransactionBriefDescription
$TransactionCF(Name)

For example, $TransactionCFLocation.

← Back to index