BypassLocalComponent

From Request Tracker Wiki
Revision as of 15:03, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I would like to create a mason Local component (/opt/rt3/local/html/MyComp) that will decide to either handle the request or pass it off to the original component (/opt/rt3/share/html/MyComp) to handle.

For example, you might want the component /Ticket/Create.html to be drastically different for just one queue, but appear as normal for all other queues. You don't want to include the code/html for both version in one component. If you did it that way you would have to update your component every time Create.html changes in the standard RT distribution.

Here's how to do this:

  1. Read this entry of the Mason FAQ.
  2. Install perl module: [=perl -MCPAN -e 'install MasonX::Request::ExtendedCompRoot']
  3. In RT_SiteConfig.pm:
@MasonParameters = (request_class  => 'MasonX::Request::ExtendedCompRoot',
                    resolver_class => 'MasonX::Resolver::ExtendedCompRoot') unless (@MasonParameters);
  1. mkdir /opt/rt3/local/html/Ticket
  2. vi /opt/rt3/local/html/Ticket/Create.html with content:
% if ($ARGS{Queue} == 1) {
<& standard=>/Ticket/Create.html, %ARGS &>
% $m->abort;
% }
This is not the component your are looking for. (Jedi mind tricks. he, he)
  1. mkdir /opt/rt3/local/html/Elements
  2. vi /opt/rt3/local/html/Elements/SelectOwner with content:
Pick me! Pick me!

Try to create a ticket in queue with id 1. Notice how SelectOwner is from local but Create.html is from share? Try to create a ticket in queue with id > 1. Not happening!

See the MasonX::Request::ExtendedCompRoot documentation for more fun.