有没有办法更改 Zend Framework 中的路由变量分隔符?
我想将 Zend Framework 生成 URL 的方式从以下位置更改为:
$routeString = '/section/:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );
... 到此...
$routeString = '/section_:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );
请注意,在第二个选项中,$routeString
中的中间斜杠被下划线替换。
当我进行此更改时,路由器将停止识别路由和变量。我觉得框架强加这样的东西很奇怪,所以我确信我在文档中遗漏了一些东西。
干杯!
I'd like to change the way URLs that Zend Framework is generating from this:
$routeString = '/section/:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );
...to this...
$routeString = '/section_:sectionName';
$route = new Zend_Controller_Router_Route(routeString, array( etc, etc... );
Note that in the second option the middle slash in $routeString
is replaced by an underscore.
When I make this change, the router stops recognizing the route and variables. I find it quite strange that the framework would impose such thing so I'm sure I'm missing something in the docs.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你可以使用 来做到这一点Zend_Controller_Router_Route_Regex。作为示例,我将在 application.ini 中为您的路线提供设置:
希望这会对您有所帮助,或者至少为您指明正确的方向。
I think you could do it using Zend_Controller_Router_Route_Regex. As an example I'll provide setup for your route in the application.ini:
Hope this will help you or at least point you in the right direction.