This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

milan.brabec69310
milan.brabec69310

Hi, I have created a simple plugin, which adds new navigation item (icon) to menu. A click on it responses with simple controller having only default action index(). It's code is as follows:

  public function index()    // <=== Action method
  {
    trace_log('Running sync of git repo content to GitLab remote...');
    Flash::success('Running sync of git repo content to GitLab remote...');
    $res = shell_exec('some_shell_script.sh');
  }

Everything works fine, except that I do not know, how to finish the controler action, what to return, to redirect back to the page/view, where I was, when I pressed the button. Any ideas? Thanks. Milan

Sam Georges
Sam Georges

Hello,

In the backend, you can return a redirect response with the Backend::redirect() method. Simply return it from your action.

public function index()
{
    return Backend::redirect('myauthor/myplugin/mycontroller/myaction');
}
milan.brabec69310
milan.brabec69310

YES, you are completely right, it works! Thanks a lot.

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.