0

我有一个名为GlossaryController的控制器,在视图中有 2 个动作indexActionanotherAction我有一个目录词汇表和index.volt文件

我想定义一个带有参数的路由,例如 http://localhost/project/glossary/another/params它应该将我重定向到带有参数的 indexAction

4

1 回答 1

0

在 app/config 文件夹中的 routes.php 文件中添加以下行:

$router->add("/glossary/another/{param1}/?{param2}", array(
    "controller" => "Glossary",
    "action"     => "another",
));

你的 anotherAction 方法将是这样的:

public function anotherAction($param1, $param2 = 0) {
//some code
}

这种方式必须发送第一个参数,第二个是可选的,您可以根据需要添加尽可能多的参数。

请参阅官方文档了解各种路由方式: https ://olddocs.phalconphp.com/en/3.0.3/reference/routing.html

于 2017-09-06T16:19:28.407 回答