Wikia

Request Tracker Wiki

Watchlist Recent changes

ForkTemplate

Here's a little chunk of code you can use in a template to send different responses depending upon a condition of your choice, without hardcoding your variants into the code:

{#Reminder to include a blank line above your actual text if not including any headers }
 
 Optional common intro
 
 {
   use RT::Template;
   my $selector = $Ticket->FirstCustomFieldValue('selector');
   my $obj = new RT::Template($RT::SystemUser);
   $obj->Load( $selector < 5 ? 'Template A' : 'Template B');
 
   #Save some cycles for plain text "templates"
   $obj->Content();
   #OR
   #Process embedded fields & expressions of true templates;
   #note that we can only meaningfully use the body
 # my($ret, $msg) = $obj->Parse();
 # $ret ? $obj->MIMEObj->stringify_body : $msg;
 }
 
 Optional common outro
 
 

This will inject the contents of another template into the current one. It's an easy way to provide some common and some specific content in a response, or to create a template which acts as a switch without having to create separate scrips for each condition. The latter effect could also be achieved through the clever use of $self->SetTemplate in CustomCondition.

my $trans = $self->TransactionObj;
return 0 unless $trans->Type eq "Create";
$self->SetTemplate( $condition ? 'foo' : 'bar' );

Pages on Request Tracker Wiki

Add a Page
857pages on
this wiki

Latest Photos

Add a Photo
28photos on this wiki
See more >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki