Hello,
I've created a little patch in order to be able to test against
substrings of entries in $Data within dtl-templates. Now I can do things
like:
<dtl if ($Data{"TicketFreeKey1"}[1,3] eq "234") { $Data{"MyString"} =
"..."; }>
AND
<dtl if ($Data{"TicketFreeKey1"}[3] eq "123") { $Data{"MyString"} =
"..."; }>
Perhaps this could be useful for someone else, too.
Regards
MD
This was diffed against 2.0.3-01.
Index: Generic.pm
===================================================================
--- Generic.pm (Revision 4)
+++ Generic.pm (Arbeitskopie)
@@ -582,16 +582,25 @@
# do template if dynamic
# --
$Line =~ s{
-
<dtl\Wif\W\(\$(Env|Data|Text|Config)\{\"(.*)\"\}\W(eq|ne|=~|!~)\W\"(.*)\"\)\
W\{\W\$(Data|Env|Text)\{\"(.*)\"\}\W=\W\"(.*)\";\W\}>
+
<dtl\Wif\W\(\$(Env|Data|Text|Config)\{\"(.*)\"\}(.*)\W(eq|ne|=~|!~)\W\"(.*)\
"\)\W\{\W\$(Data|Env|Text)\{\"(.*)\"\}\W=\W\"(.*)\";\W\}>
}
{
my $Type = $1 || '';
my $TypeKey = $2 || '';
- my $Con = $3 || '';
- my $ConVal = defined $4 ? $4 : '';
- my $IsType = $5 || '';
- my $IsKey = $6 || '';
- my $IsValue = $7 || '';
+ my $KeyLength = $3 || '';
+ my $Con = $4 || '';
+ my $ConVal = defined $5 ? $5 : '';
+ my $IsType = $6 || '';
+ my $IsKey = $7 || '';
+ my $IsValue = $8 || '';
+
+ my $KeyStart = 0;
+ $KeyLength =~ s/[\[\]]//g;
+ if ($KeyLength =~ /(\d*),(\d*)/) {
+ $KeyLength = $2;
+ $KeyStart = $1;
+ }
+
# --
# do ne actions
# --
@@ -608,6 +617,7 @@
if (!defined($Tmp)) {
$Tmp = '';
}
+ if ($KeyLength ne '') { $Tmp = substr($Tmp,
$KeyStart, $KeyLength); }
if (eval '($Tmp '.$Con.' $ConVal)') {
$GlobalRef->{$IsType.'Ref'}->{$IsKey} = $IsValue;
# output replace with nothing!
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev