我正在寻找一些简单的东西,但经过多次搜索后我不知道该怎么做。我查看了 Zend 1.12 Route 的文档,但我不太明白。
我在 Zend Framework 中有这些页面:application/views/scripts/index/
索引.phtml
联系方式.phtml
在 application/views/layouts/scripts/layout.phtml 中
例如,我想链接到 contac.phtml 。我正在寻找类似的事情:
$this->url('contact')
然后,它重定向到页面联系人...但我尝试在 bootstrap.php 中添加一条路由,但我真的不知道如何...
$router->addRoute('contact',
new Zend_Controller_Router_Route('application/scripts/index/contact.phtml'));
谢谢你,
David
我认为这是 zend 框架中路由的简单代码:
在index.php 上你不应该碰任何东西。创建项目时将其保留为 Zend 默认值
-
在projectHomeDirectory/application/Bootstrap.php 上包括:
protected function _initRoutes()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
include APPLICATION_PATH . "/configs/routes.php";
}
-
在projectHomeDirectory/application/configs/下创建一个routes.php文件,并在其中添加您想要的所有路由,例如:
$route = new Zend_Controller_Router_Route(
'author',
array(
'controller' => 'user',
'action' => 'index'
)
);
$router->addRoute('author', $route);
当然,您随后需要创建 UserController、用户模型、示例模块和视图。
有用的链接:
- http://framework.zend.com/manual/1.12/en/zend.controller.router.html http://framework.zend.com/manual/1.12/en/zend.controller.router.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)