[英]Zend Framework: Need help setting up Routing
how do i set up routing as follows 我如何如下设置路由
these work with the standard routing 这些与标准路由一起使用
/posts => index action (listing)
/posts/view => view action (individual post)
/posts/add => add action
/posts/edit => edit action
what abt these? 这些呢?
/posts
can by filtered based on 1 or more query strings, in any order. 可以基于1个或多个查询字符串以任意顺序过滤
/posts
。 eg. 例如。
/posts/tagged/tag1 /posts/tagged/tag1/timeframe/1w => fyi. / posts / tagged / tag1 / posts / tagged / tag1 / timeframe / 1w => fyi。 1w means 1 week /posts/timeframe/1w/tagged/tag1 => can be in any order /posts/sortby/dtposted => more options maybe added
1w表示1周/ posts / timeframe / 1w / tagged / tag1 =>可以按任意顺序/ posts / sortby / dtposted =>可以添加更多选项
how can i handle these? 我该如何处理? i tried
我试过了
$route = new Zend_Controller_Router_Route(
'posts/*',
array(
'controller' => 'posts',
'action' => 'index'
)
);
$router->addRoute('postsIndex', $route);
but of cos, all routes to posts/*
goes to the index controller. 但是,对于cos,所有到
posts/*
路由都到达索引控制器。 not what i want 不是我想要的
You dont need to use a route for those url's if your using proper naming conventions it should naturally. 如果您自然使用适当的命名约定,则无需为这些url使用路由。
class PostsController extends Zend_Controller_Action{
public function viewAction(){
}
public function editAction(){
}
public function addAction(){
}
public function indexAction(){
}
}
I suggest going back to basics and learning how controllers models and views work in the zend framework before trying to understand routing :) 我建议回到基础知识,并在尝试理解路由之前学习控制器模型和视图在zend框架中的工作方式:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.