[Catalyst] Use of uri_for with CaptureArgs

Alan Hicks ahicks at p-o.co.uk
Mon Feb 4 12:09:25 GMT 2008


Hi,

I've started using CaptureArgs and PathPart and find them excellent and 
easy to use.

I've probably missed something from the docs but does anyone have a best 
practice in using uri_for or an alternative for generating url's? the 
case I'm having difficulty with is to generate a url with more than one 
id such as /artist/*/images/*  An example might demonstrate what I'm 
trying to achieve:

MyApp::Controller::Artist
sub artist_setup : Chained('/') : PathPart('artist') : CaptureArgs(1)  {}
/artist/*

 From within MyApp::Controller::Artist uri_for($id, 'show') does the 
right thing and produces http://localhost/artist/*/show

MyApp::Controller::Artist::Images
sub images_setup : Chained('/artist/artist_setup') PathPart('images') 
CaptureArgs(1)  {}
/artist/*/images/*

 From within MyApp::Controller::Artist::Images uri_for($id, 'show') 
gives http://localhost/artist/images/*/show which does not take into 
account the artist id so do I have to build uri_for('/artist', 
$artist_id, 'images', $id, 'show') which appears cumbersome.

Any suggestions appreciated,
Alan




More information about the Catalyst mailing list