Off the cuff (so I'm not even sure it parses):
Router::connect(
"/articles/:year/:month/:day/:slug",
array("controller" => "articles", "month" => null, "day" => null,
"slug" => null),
array('year' => $Year, 'month' => $Month, 'day' => $Day, 'slug' =>
"[A-Za-z0-9_\-]+")
);
Router::connect("/articles/:action", array("controller" =>
"articles"), array("action" => "list|controller|actions|here"));
Router::connect("/articles/:slug", array("controller" => "articles",
'action' => 'view'), array("slug" => "[A-Za-z0-9_\-]+"));
All the variables used are magic variables that are available in
config/routes.php. Also, passing null to keys in the second parameter
makes those parameters optional, so that first route takes care of all
your date / date + slug URLs.
On Nov 11, 2:12 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> hi folks,
>
> I'd like to have the following urls:
>
> /articles
> /articles/$category_slug
> /articles/$year
> /articles/$year/$month
> /articles/$year/$month/$day
> /articles/$year/$month/$day/$article_slug
>
> I've been looking at routes but hit a mental block, most likely due to
> a lack of regex experience. Should I:
>
> a) follow cake's pages->display method and do a switch on the number
> of args (with some type checking)
> b) use cake's routes to redirect a single call to 3 different methods
> (index, category, view)
> c) use cake's routes to do regex and pass the correct value in params
> to a single method
>
> I think C is the answer, but I need a bit of help getting there!
>
> Thanks,
>
> Jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---