[英]Zend Framework: Need help setting up Routing
我如何如下設置路由
這些與標准路由一起使用
/posts => index action (listing)
/posts/view => view action (individual post)
/posts/add => add action
/posts/edit => edit action
這些呢?
可以基於1個或多個查詢字符串以任意順序過濾/posts
。 例如。
/ posts / tagged / tag1 / posts / tagged / tag1 / timeframe / 1w => fyi。 1w表示1周/ posts / timeframe / 1w / tagged / tag1 =>可以按任意順序/ posts / sortby / dtposted =>可以添加更多選項
我該如何處理? 我試過了
$route = new Zend_Controller_Router_Route(
'posts/*',
array(
'controller' => 'posts',
'action' => 'index'
)
);
$router->addRoute('postsIndex', $route);
但是,對於cos,所有到posts/*
路由都到達索引控制器。 不是我想要的
如果您自然使用適當的命名約定,則無需為這些url使用路由。
class PostsController extends Zend_Controller_Action{
public function viewAction(){
}
public function editAction(){
}
public function addAction(){
}
public function indexAction(){
}
}
我建議回到基礎知識,並在嘗試理解路由之前學習控制器模型和視圖在zend框架中的工作方式:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.