When I list tickets I want to show the first 3 lines of the ticket
message for each ticket.
I am using the following patch to achieve this, but it is quite a hack.
Can someone recommend a cleaner solution.
local/html/Elements/CollectionList
##### BEGIN TicketPreview in Search/Results.html #####
##### Installation: cp share/html/Elements/CollectionList
local/html/Elements/
##### then open the copy and insert this code between the
lines
##### "$m->callback( CallbackName => 'EachRow', ... );"
##### and
##### "$m->comp('/Elements/CollectionAsTable/Row', ... );"
##### Important!!! you need to configure the DefaultSearchResultFormat
##### otherwise ht preview won't be displayed
##### Example: etc/RT_SiteConfig.pm
##### Set ($DefaultSearchResultFormat, qq{
##### ...
##### '__Preview__',
##### ...
##### });
$column_map->{Preview} = {
'align' => undef,
'value' => sub {
my $res = $record->Attachments();
my $attachment = $res->First;
return '' unless $attachment;
my $content = $attachment->Content;
return '' unless $content;
open(my $fh, '<', \$content) or die $!;
my @preview = ();
while(my $line = <$fh>) {
# rm html tags
$line =~ s/\<.*?\>//xmsg;
# ignore empty lines
push(@preview, $line) if ($line !~
m/^\s*$/xms);
last if scalar @preview >= 3;
}
return @preview;
},
'style' => undef
};
##### END TicketPreview in Search/Results.html #####
---------
RT 4.4 and RTIR Training Sessions https://bestpractical.com/training
* Washington DC - May 23 & 24, 2016