Thanks Brian. You were right on. Removing the parentheses solved the problem. I doubt I would have arrived at this solution even if I continue spending more hours figuring it out myself. I used the sample code from the Cookbook 10.4.5.3 and didn't suspect any problem in the code.
And thank you for the tip on using the pass array. This was something new that I didn't know. And I prefer using it now than having to refer to $this->params for all the 4 variables. Steve On Feb 17, 8:15 am, brian <[email protected]> wrote: > I've had this one before. I think the solution is to remove the > parentheses from the regexps > > Router::connect('/press_releases/:year/:month/:day/:slug', > array('controller'=>'presses','action' => 'view'), > array( > 'year' => '[12][0-9]{3}', > 'month' => '0[1-9]|1[012]', > 'day' => '0[1-9]|[12][0-9]|3[01]' > ) > ); > > Incidentally, if you want to pass those params to the controller > method you can add them to the pass array: > > Router::connect('/press_releases/:year/:month/:day/:slug', > array('controller'=>'presses','action' => 'view'), > array( > 'year' => '[12][0-9]{3}', > 'month' => '0[1-9]|1[012]', > 'day' => '0[1-9]|[12][0-9]|3[01]', > 'pass' => array('year', 'month', 'day', 'slug') > ) > ); > > function view($year = null, $month = null, $day = null, $slug = null) > { > ... > > On Tue, Feb 17, 2009 at 5:16 AM, stevel <[email protected]> wrote: > > > Can someone please help figure what is wrong with my route? I have > > been trying for hours and yet could not figure out what the mistake > > is. I have the following route defined: > > > Router::connect('/press_releases/:year/:month/:day/:slug', > > array('controller'=>'presses','action' => 'view'), > > array( > > 'year' => '[12][0-9]{3}', > > 'month' => '(0[1-9]|1[012])', > > 'day' => '(0[1-9]|[12][0-9]|3[01])' > > ) > > ); > > > And here's my url: > > ... /press_releases/2009/01/26/media-100-winner > > > And my debug output for $this->params shows: > > > Array > > ( > > [pass] => Array > > ( > > [0] => 26 > > [1] => media-100-winner > > ) > > > [named] => Array > > ( > > ) > > > [year] => 2009 > > [month] => 01 > > [day] => 01 > > [slug] => 26 > > [plugin] => > > [controller] => presses > > [action] => view > > [url] => Array > > ( > > [ext] => html > > [url] => press_releases/2009/01/26/media-100-winner > > ) > > ..... > > ) > > > Why are [day] => 01 and [slug] => 26 instead of [day]=>26 and [slug] > > =>"media-100-winner" > > > If someone could help throw some light into this, it'll be most > > appreciated. > > Thanks in advance. > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
