Unexpected output in implementing action stack in zend framework.What is the correct flow of actionstack or how does it work? -


the action stack work fines below code problem output came in unexpected patter.. @ end of code explain output getting , desired out put . using action stack first time dont know how request processed

        plugin class     -----------------------     class my_plugins_actionstack extends zend_controller_plugin_abstract     {      public function dispatchloopstartup(zend_controller_request_abstract $request)     {                      $action_stack = new zend_controller_action_helper_actionstack();                     $action_stack->actiontostack('index', 'index', 'default', array('position' => 'right'));                     $action_stack->actiontostack('index', 'index', 'user', array('position' => 'left'));                     $action_stack->actiontostack('index', 'index', 'hr', array('position' => 'center'));      }     base controller     ------------------      class my_controller_base extends zend_controller_action     {      public function predispatch()         {             $position = $this->_request->getparam('position', false);               if ($position) {                     $this->_helper->viewrenderer->setresponsesegment($position);             }           }           public function init()         {           }     }     default controller     ---------------------------     class default_indexcontroller extends mlive_controller_base     {            public function init()         {             /* initialize action controller here */         }          public function indexaction()         {          }       }     index.phtml in default controller     ============     default module     hr controller     -----------------     class hr_indexcontroller extends mlive_controller_base     {          public function init()         {             /* initialize action controller here */         }          public function indexaction()         {         }       }     index.phtml in hr controller     ============     hr module     user controller     ----------------------     class user_indexcontroller extends mlive_controller_base     {          public function init()         {             /* initialize action controller here */         }          public function indexaction()         {          }       }     index.phtml in user controller     ============     user module     -----------------------------------------------     , layout looks      layout.phtml     ------------------------     basic layout     <div>         <h2><u>left:</u></h2>         <?=$this->layout()->left?>     </div>     <div>         <h2><u>center:</u></h2>         <?=$this->layout()->center?>     </div>     <div>         <h2><u>right:</u></h2>          <?=$this->layout()->right?>     </div>     <div>  output  ---------------------------  output  default module  --------------------------  basic layout left: user module center: right: hr modulethis user module content: default module   ----------------------------------------------- output user module ------------------------------------------------ basic layout left: hr module center: right: hr modulethis default module content: user module --------------------------------- output hr module ----------------------------------- basic layout left: user module center: right: hr modulethis default module content: hr module  desired output ---------------- ---------------------------  output  default module  --------------------------  basic layout left: user module center: hr module right: default module content: default module   ----------------------------------------------- output user module ------------------------------------------------  basic layout left: user module center: hr module right: default module content: user module --------------------------------- output hr module -----------------------------------  basic layout left: user module center: hr module right: default module content: hr module 

to answer how actionstack work?

action stack executes actions in last-in first-out order. in example add modules in order: default, user, hr - executed in order hr, user, default, your request action. your request action exists on stack first default , gets executed last.

your output not expected because 'position' param gets set when last action on stack runs, before real action gets run - it's getting stuck on 'right' - output action being appended segment.

as stated elsewhere, action stacks heavy , slow add lot of iterations dispatchloop process.

a better way of doing trying use placeholders , partials moving of common code want common library.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -