开发者

Use a controller in another one using zend

开发者 https://www.devze.com 2022-12-13 01:56 出处:网络
I have a 开发者_运维问答controller for example \"Price\" also another one \"Testprice\" both using the same database table and the functionality are same only difference for \"Testprice\" the table ha

I have a 开发者_运维问答controller for example "Price" also another one "Testprice" both using the same database table and the functionality are same only difference for "Testprice" the table have field test value true and for "Price" test = false . How can i extend the "Price" controller to this "Testprice" :)


You can make Testprice forward to Price with a "test" parameter present.

$this->_forward('index', 'price', null, array('test' => 1));

And then check for "test" request parameter in the Price controller's index action

Another option is to configure the Zend router in your application.ini:

resources.router.routes.testprice.route = "testprice/"
resources.router.routes.testprice.defaults.controller = "price"
resources.router.routes.testprice.defaults.action = "testprice"

And it will call testpriceAction in the Price controller for /testprice/ URI


just use 1 class Price with a member Test, that you set tot true if you are using it as a test.

0

精彩评论

暂无评论...
验证码 换一张
取 消