[Catalyst] Help System - Can a controller's index capture the
remainder of the path as a series of arguments?
Eden Cardim
edencardim at gmail.com
Mon Apr 11 19:51:41 GMT 2011
>>>>> "Kyle" == Kyle Hall <kyle.m.hall at gmail.com> writes:
Kyle> Thanks to Bill and David the info. I'm still learning how to use
Kyle> Catalyst, it's almost overwhelming when compared to CakePHP ( which is
Kyle> what I started with as my first framework ) here is what I've got:
Kyle> My button: <a href="[% c.uri_for('/help', c.action ) %]"
Kyle> class="button" id="menu-help">Help</a>
Kyle> My Help controller:
Kyle> sub index : Chained('/') PathPart('help') Args {
Kyle> my ( $self, $c, @path ) = @_;
Kyle> my $path = join('/', @path);
Kyle> $c->stash->{template} = "help/$path.tt";
Kyle> }
Kyle> Seems to work fine. Any suggestions for improvements?
Is there any non-static content in the help files? If not, you can get
away with serving the plain files straight from root/help via:
--8<---------------cut here---------------start------------->8---
MyApp->config->{'Plugin::Static'}{dirs} = [ 'help' ];
--8<---------------cut here---------------end--------------->8---
As usual you'll want to serve that straight via apache or whatever in
production.
And in your templates:
--8<---------------cut here---------------start------------->8---
<a href="[% c.uri_for('/help', c.req.path) %]"/>Help</a>
--8<---------------cut here---------------end--------------->8---
--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list