[Catalyst] Dispatching question
Bill Moseley
moseley at hank.org
Mon Nov 14 14:09:19 CET 2005
On Mon, Nov 14, 2005 at 03:06:41PM +1000, Maxim Nechaev wrote:
> Hi, all.
>
> Catalyst::Manual::Intro.pod declare "Unrestrained URL-to-Action
> Dispatching" in Catalyst.
> Well, but i think all of dispatching types (Path, Regex, Global,
> Local) badly link up URL and his handler.
> For example, i have some forum Controller, begining with url
> "/forum/". Later, i want move it to "/communication/" or
> "/communication/forum/". What i need to do it?
As sri points out, use "Local" actions in the controller. And for the
"default" action for the controller you can now use "Path" with an
empty path. E.g.:
package App::C::Forum;
# handle /forum requests
sub root : Path {
...
}
# handle /forum/edit
sub edit : Local {
...
}
Then in your templates use the new uri_for method:
<a href="[% c.uri_for('edit') %]">Edit this item</a>
<a href="[% c.uri_for('delete') %]">Delete this item</a>
Then to move the feature to another location you can just move the
controller and modify its package.
Sometimes I wonder why the package couldn't default to the name of the
file relative to the lib dir. Then all it would take is moving the
controller file.
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list