在我的管理模块中,在索引控制器中,我有多个过滤选项。根据参数,过滤非常简单,即:
http://www.site.com/admin/pages/by/date_added/order/asc
-> This orders the pages by "date_added" ascending
http://www.site.com/admin/pages/status/published
-> This shows only the pages with status "published"
http://www.site.com/admin/pages/category/cars
-> This show only the pages under the "cars" category.
然后在我的应用程序引导程序中,我构建了这样的路线:
$route = new Zend_Controller_Router_Route_Regex("^admin/pages/status/([a-z,_]+)$",
array(
"module" => "admin",
"controller" => "pages",
"action" => "index"
),
array(
1 => 'by',
2 => 'order',
)
);
$router->addRoute("admin/pages/order", $route);
问题是我不知道如何组合所有这些参数,但也让它们成为可选的。例如我不想有这样的链接:
http://www.site.com/admin/pages/by/date_added/order/asc/category/cars
或者...
http://www.site.com/admin/pages/category/cars/status/published