
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:

Hi Manfred, thanks for the cool patch. Nice work. :-) Normally I would say, this is a very cool patch for the cvs head, but we decided to keep the logic out from the *.dtl files (just have on place with logic -> Kernel/Modules/*.pm). So in OTRS 2.0 we removed many dtl-if options. dtl-if will be still supported but is not appreciated. :-) Anyway, thanks for sharing your ideas. :-) -Martin Manfred Dohmen wrote:
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:
AND 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{ -
W\{\W\$(Data|Env|Text)\{\"(.*)\"\}\W=\W\"(.*)\";\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
participants (2)
-
Manfred Dohmen
-
Martin Edenhofer