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:
package myapp::templates
##n ormal controller setup stuff
sub templates :Chained('/') CaptureArgs(0)
{
## Get the templates list from the model
}
sub list :Chained('templates') PathPart('') Args(0)
{
## Show a list of all templates found by the template action
}
sub template :Chained('templates') PathPart('') CaptureArgs(1)
{
## Retrieve info about a particular template
}
sub view :Chained('template') PathPart('') Args(0)
{
## View the template found by the template action
}
sub edit :Chained('template') PathPart('edit') Args(0)
{
my ($self, $c) = @_;
if( $c->request->method eq 'GET' )
{
##Just show the Form
}
elsif($c->request->method eq 'POST')
{
## Do some form processing and if everything saves okay...
$c->response->redirect("/templates");
}
}
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?
--john
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/