> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of John > Napiorkowski > Sent: August 30, 2006 8:08 PM > To: catalyst@lists.rawmode.org > Subject: [Catalyst] Generate a URL for a given action > > Hi, > > I'm sure this is a no brainer but I just can't find it > anywhere. Basically what I am trying to find out is if there > is a programmatic way to discover the url for a given action > in controller just by using the action name. Here is the > example I am trying to deal with:
You've got it backwards. In your example the `list', `template' and `view' actions all map to `/templates'. You should have something like: package MyApp::Controller::Templates; sub template :Chained('/') :PathPart('') :CaptureArgs(1) {...} sub list :Chained('template') :Args(0) {...} sub view :Chained('template') :Args(0) {...} See http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7001/lib/Catalyst/Dispat chType/Chained.pm#Introduction for a good example. > *snip* > Basically I'd like to replace the hardcoded path in the > redirect("/templates") since I am not too sure where this app > will eventually sit in the web hierarchy. Now, the docs for > $c->get_uri says you can pass an action to it to get the url, > which seems to me what I want. If I did: > > $c->response->redirect($c->uri_for('templates')); > > Would this work correctly even if this controller ends up > deeply nested? `$c->response->redirect($c->uri_for('templates'))' should work, since it's a path relative to the current controller. The uri_for method should prepend the URI with your app's base URL and the path to the controller, so that should be all you need. > --john > > > > _______________________________________________ > List: Catalyst@lists.rawmode.org > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.rawmode.org/ > Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/