开发者

I want to control with one Controller some other Controllers with their own models (not _forward)

I'm new to zend framework and its my first question I asked in the internet... sorry for my bad english! I have got a problem and in some hours I would jump out of the window ;) I have one controller A, then I need 4 other controllers (B, C,D,E) to call their models and give the answer to the controller A. Controller A send it after this to the view.

Zend_Framework sadly doesn't allow something like this:

Class Arcticle_SteuerController {
    public function showAction() {
    .....
          $text = new Article_TextController();
          $opt = new Article_OptionController();
          $dates =  new Article_DatesController();

          $varText = $text->showTextAction();
          $varOpt = $opt->showOptAction();

          $this->view->varText;
          $this->view->varOpt;
            ....
    ....
    }
}

I have got a problem to put everything in one Controller, because every Controller has its own model and this is wrong designing I think so. So I want to try to call another function from another class.

I find something, that not every Action needs a view... like this:

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($this->view)
             ->setNoController(true);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

The prob开发者_开发百科lem is that _forward only call the function after the current function. Can anybody help me? Is there a chance, or do I have to put everything in one Controller?

Hope and thanks for help

Best regards Tom


ZF isn't designed as an HMVC framework, but you can pull this off. One way might be by using an action stack helper/plugin. Check out the documentation: http://framework.zend.com/manual/en/zend.controller.actionhelpers.html

You should be able to get back html from those controllers' views. I'm not sure how scalable this method is if used overall to simulate an HMVC, however.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜