使用路由重命名 Zend 模块 [英] rename a zend module with routes

查看:56
本文介绍了使用路由重命名 Zend 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将items"模块重命名为products"的方法,它在大多数情况下都有效,但在 url 中没有明确设置控制器或操作时则无效.例如,example.com/products 不起作用,而 example.com/items 起作用,并且与 example.com/products/index/相同索引.任何想法如何修复它,或使控制器和动作可选?

I have a route to rename the 'items' module to 'products', and it works in most cases, but not when there is no controller or action explicitly set in the url. For example, example.com/products does not work, while example.com/items does, and is the same as example.com/products/index/index. Any ideas how to fix it, or to make controllers and actions optional?

$router->addRoute('item-alias', new Zend_Controller_Router_Route('products/:controller/:action', array(
    'module'=>'items'
)));

<小时>

当我将其更改为

$router->addRoute('item-alias', new Zend_Controller_Router_Route('products/:controller/:action/*', array(
    'module'=>'items'
    'controller'=>'index',
    'action'=>'index'
)));

'*' 允许附加额外的可选参数,例如example.com/products/index/index/page/2

The '*' allows additional optional parameters to be appended, e.g. example.com/products/index/index/page/2

推荐答案

设置控制器和动作的默认值.这样,它们将是可选参数,可以跳过.

set default values for controller and action. That way they will be optional parameters and can be skipped.

这篇关于使用路由重命名 Zend 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆