0

How can I use multi controller in one page? I used:

Yii::$app->controller->action();

How can I access another controllers?

3
  • Maybe runAction() is what you need: link Commented Mar 9, 2016 at 11:33
  • 2
    You should not do that. Better solution is move functionality that you wanna use to some component/utility class. By doing this that way you'll be able to run this function across all application. Commented Mar 9, 2016 at 11:35
  • I want to use PostController actions in every page, how can i use it? Commented Mar 9, 2016 at 11:37

1 Answer 1

1

You can create a new class and put your actions in the calass, after that create a object in the page you want to use it.

for example:

$object = new fontend\controllers\NewClassName;

$object -> YourAction();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.