views:

77

answers:

2

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
i dont know how to pass parameter . Can u give me an example code ?
Nisanth
Here you are. I've added the code
Ivan Krechetov
Thank u i will check with that :)
Nisanth
I've added a router config option. May be you like it better.
Ivan Krechetov
+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
and set it in predispatch() method based on $this->_getParam('test');
Tomáš Fejfar