[Top] [All Lists]

Re: Routing first parameter in URL to an action

Subject: Re: Routing first parameter in URL to an action
From: Lucca Mordente
Date: Mon, 1 Mar 2010 07:55:45 -0800 PST
if its not calling the view method, try to add  \- to your regex as


else if the parameter just isn't being passed, add the 'pass' option
to route:

     array('controller' => 'posts', 'action' => 'view'),
     array('slug' => '^[a-zA-Z0-9_]{1,}$', 'pass'=>array('slug'))

hope it helps (:

On 1 mar, 12:39, jbov <> wrote:
> I have set up a blog using URL slugs. Say my domain is and the
> title for my first post is "I lost my shoe". My blog posts are
> displaying at Easy as pie, er, cake.
> I want to route it so the first parameter in the url is the slug. So
> would map to controller => posts, action =>
> view. Below is my routing, but I'm missing something because it's not
> passing the slug to the view method properly. Or maybe it's not
> calling the view method. Any advice?
> Router::connect(
>      '/:slug',
>      array('controller' => 'posts', 'action' => 'view'),
>      array('slug' => '^[a-zA-Z0-9_]{1,}$')
> );

Check out the new CakePHP Questions site and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
cake-php+unsubscribe@xxxxxxxxxxxxxxxx For more options, visit this group at

<Prev in Thread] Current Thread [Next in Thread>