[cgiapp] How to retrieve 'action'
Richard Jones
ra.jones at dpw.clara.co.uk
Wed Dec 3 09:11:29 EST 2008
Jason Purdy wrote:
> This is when CGI::Application::Dispatch helps out, tremendously. Once
> you set it up, the action in your case translates to the runmode along
> with optional parameters.
>
> http://search.cpan.org/~markstos/CGI-Application-Dispatch-2.14/lib/CGI/Application/Dispatch.pm
Yes, sorry, should have said I'm using Dispatch, but it's not always
helpful, as I have some rules that mean /myapp/foo/do_stuff points to
the do_stuff() method in Foo.pm, but /myapp/admin/bar/do_stuff points to
do_stuff() in Admin::Bar.pm not Admin.pm. So setting debug => 1 in
Dispatch gives me "app = foo" in the 1st example - that's OK. But in the
second, "app = bar", whereas I want to capture 'admin'.
And runmode is not actually what I'm after, eg default(), do_stuff() are
all runmodes of Foo.pm, and it's 'foo' I'm after, as in
<http://localhost/myapp/foo>.
Have solved it (I think) in the template using c.query.path_info, as in:
[% FOREACH action_links # hash defined previously %]
<a href="[% c.query.url %]/[% link %]"
[% IF c.query.path_info.match('^/' _ link) %]id="selected"[% END %]>
[% label %]</a>
[% END %]
--
Richard Jones
More information about the cgiapp
mailing list