views:

22

answers:

1

This is a rails 3 code

match '/articles(/:year(/:month(/:day)))' => 'posts#index'"

that match url where some parts can be omitted to post controller and index action

What is the most elegant way to make the same in Zend Framework

+1  A: 

I think this route should be enough:

$route = new Zend_Controller_Router_Route(
    'articles/:year/:month/:day',
    array(
        'year'       => date("Y"),
        'month'      => date("m"),
        'day'        => date("d"),
        'controller' => 'post',
        'action'     => 'index'
    ),
    array(
        'year' => '\d+',
        'month' => '\d+',
        'day' => '\d+',
    )
);

Defaults to current day/month/year

Keeper