> > On Thu, Sep 01, 2011 at 12:05:57PM +1000, Stuart Browne wrote:
> > > > I'd just do a custom display of that Custom Field and build the link
> > > > myself, rather than trying to extend the link to functionality.
> > > >
> > > > You'll probably find the ShowComponentName callback useful
> > >
> > > Thanks for the suggestion.
> > >
> > > This is what I ended up with.
> >
> > I actually meant that you should use that callback to change what
> > component is used for display.  You're passed $Name, assign to it by
> > reference (say ShowCustomFieldCustomLink) if you're in the right
> > custom field and then write your custom code into the
> > ShowCustomFieldCustomLink element in local/
> >
> > That callback isn't intended as a place to printf from
> 
> Ahh, righteo.  Will look at it again if I have some time ;)

Ok, now that you've said that, the code read makes more sense (not a 
programmer! So very much not a programmer!).

Ended up with:

--- 
/opt/rt3/local/html/Callbacks/MingleCardNumberLink/Elements/ShowCustomFields/ShowComponentName
<%INIT>
if ($CustomField->Name eq 'Mingle Card Number') {
        $$Name = 'DisplayMingleCardLink';
}
</%INIT>
<%ARGS>
$Name => undef
$CustomField => undef
$Object => undef
</%ARGS>

--- /opt/rt3/local/html/Elements
% my $output = $Object->Content;
%
% my $MingleCard    = $Object->Content;
% if (defined $MingleCard && $MingleCard) {
%       my $MingleProject = $Object->Object->FirstCustomFieldValue('Mingle 
Project');
%       if ($MingleProject eq '') {
%               $MingleProject = 'dnr';
%       }
%       $output = sprintf("<a target='_new' 
href='http://URL/projects/%s/cards/%s'>%s</a>", $MingleProject, $MingleCard, 
$MingleCard);
% }
<%$output|n%>
<%ARGS>
$Object => undef
</%ARGS>
---

The documentation is fairly vague on custom callbacks.  Thanks to 
http://www.runpcrun.com/node/272 for the clue as to where the custom callback 
should be located.

Stuart
--------
RT Training Sessions (http://bestpractical.com/services/training.html)
*  Chicago, IL, USA  September 26 & 27, 2011
*  San Francisco, CA, USA  October 18 & 19, 2011
*  Washington DC, USA  October 31 & November 1, 2011
*  Melbourne VIC, Australia  November 28 & 29, 2011
*  Barcelona, Spain  November 28 & 29, 2011

Reply via email to