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
-~----------~----~----~----~------~----~------~--~---

Reply via email to