1

Can we redirect controller to another controller in such a way that previous controller continue its working in its execute method and next controller works render the layout at a same time? and after executing it returns the next controller

e.g

public function execute()
{
       //do what ever we want

    return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
       $resultRedirect->setPath('abc/def/ghi');
}

is this possible?

2

Re-direction to another controller is fine and no code will be executed if it not called or included inside the execute()

So, basically you should call that function on your execute() which has re-direction function and so.

For Example :

public function execute()
{
   //do what ever we want
  return $this->abc(); // call internal function then next line won't execute
  return $resultRedirect->setPath('abc/def/jklmno');
}
public function abc()
{
   $resultRedirect->setPath('abc/def/ghi');
}

I could partially understood your requirement and may be I would say re-direction based on certain conditions would help you as far as I guess.

NOTE : Each page have a separate controller.

Hope this helps.

  • but after returning to function it won't read next code then it means there is no way i can run 2 controllers at a same time like "it shows to user $resultRedirect->setPath('abc/def/ghi'); controller" and actually executing previous controller work – Asad Ullah Apr 29 at 11:42
  • thanks i thought maybe there is a way. thanks – Asad Ullah Apr 29 at 11:43
  • See controller is and action, which has specific functionality to be executed when an specific action is triggered. So for each page has a controller without that you won't be displaying a page @AsadUllah – Prathap Gunasekaran Apr 29 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.