How to render from backend to frontend?

[Hi guys,

if User is logging out in Backend, I want to render to index.php in folder views/site/index in Frontend. If i’ll try like this


 public function actionLogout() {

 return $this->render(\Yii::$app->urlManagerFrontend->baseUrl . '/home');       	

    }

I’ll get error


E:\xampp\htdocs\basic\backend\views\basic/frontend/web/index.php/home.php

If I’ll try like this:


    public function actionLogout() {

        return $this->render('@frontend/views/site/index');

    }

or like this:


   Yii::setAlias('@example',Url::to('E:\xampp\htdocs\basic\frontend\views\site\index'));

 	return $this->render('@example');

application won’t switch to Frontend. Any ideas how to fix this?

Just want to mention that, if you used the basic application template and an admin module, your life would be so much easier!

Because it will always be cumbersome, and hacky, trying to make two separate applications cooperate like that; that is what the advanced application template gives you: two separate applications, with a common base.

In the case of a basic application and an admin module, the user would admin/backend in the admin/backend module. For example: your_glorious_site/admin.

Since a module is essentially an application within an application, you will get all the benefits and none of the cons.

Use redirect instead of render.