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" :)
+1
A:
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
Ivan Krechetov
2009-11-26 11:15:34
i dont know how to pass parameter . Can u give me an example code ?
Nisanth
2009-11-26 11:19:00
Here you are. I've added the code
Ivan Krechetov
2009-11-26 11:19:58
Thank u i will check with that :)
Nisanth
2009-11-26 11:24:38
I've added a router config option. May be you like it better.
Ivan Krechetov
2009-11-26 11:27:33
+1
A:
just use 1 class Price with a member Test, that you set tot true if you are using it as a test.
Natrium
2009-11-26 11:17:16
and set it in predispatch() method based on $this->_getParam('test');
Tomáš Fejfar
2009-11-26 14:00:14