I want to put a link from the backend to the site/index action of the frontend. I read this article https://github.com/yiisoft/yii2/issues/1578 but it’s not clear to me. Can anyone explain me this in full detail? Thanks.
I want to put a link from the backend to the site/index action of the frontend. I read this article https://github.com/yiisoft/yii2/issues/1578 but it’s not clear to me. Can anyone explain me this in full detail? Thanks.
This is the most important part of the post:
In your backend application config you should add additional ‘UrlManager’ component with different name and configuration equals to the one used at front end application:
return [
'components' => [
'urlManager' => [
// here is your backend URL rules
],
'urlManagerFrontEnd' => [
// here is your Front-end URL rules
],
],
];
Then you should invoke following to compose front-end URL:
Yii::$app->urlManagerFrontEnd->createUrl();
I put this but it’s not working:
'urlManagerFrontEnd' => [
'class' => 'yii\web\urlManager',
'baseUrl' => Yii::getAlias('@frontend') . '/frontend/web',
'enablePrettyUrl' => true,
'showScriptName' => false,
],
When I invoke createURl it doesn’t create a valid URL.