[rt-users] Filter ticket text for display?

Toby Darling darling at ccdc.cam.ac.uk
Mon Jul 9 10:52:49 EDT 2007


Hi Gary
> Hi folks -- is there a hook to filter or process the ticket history texts
> (email bodies) when they're displayed?  We'd like to turn certain pieces of
> text (identified by regex) into html links.

http://wiki.bestpractical.com/view/CustomizingWithCallbacks
I'm not sure how current it is, but it's working for me on RT 3.4

Essentially I created a file in the local/share/request-tracker3.4 tree 
called html/Callbacks/CCDC/Ticket/Elements/ShowMessageStanza/Default
containing:

<%init>
my $val = $$content;
use bytes;
$val =~ s/(s?http|https):[\w\/\.:+\-]+/<a href="$&">$&<\/a>/gi;
$$content = $val;
</%init>
<%args>
$content => undef
</%args>


If you capture anything in the <regexp>, you can use $1, $2, ... in the 
replacement, as well as $& for the whole matched string.

$val =~ s;(bug|bz|bugzilla)\s*(\d{4,6});<a 
href="http://bugzilla/show_bug\.cgi\?id=$2">$&</a>;gi;

would turn "bug 1234" into a clickable link.



LEGAL NOTICE
Unless expressly stated otherwise, information contained in this
message is confidential. If this message is not intended for you,
please inform postmaster at ccdc.cam.ac.uk and delete the message.
The Cambridge Crystallographic Data Centre is a company Limited
by Guarantee and a Registered Charity.
Registered in England No. 2155347 Registered Charity No. 800579
Registered office 12 Union Road, Cambridge CB2 1EZ.



More information about the rt-users mailing list