sifa786
(Ffelaar)
May 31, 2014, 11:58pm
1
I want to put a link on my frontend app called ‘Admin’, which links to the \backend\web\index.php file … how should I change the NavBar url?
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['@frontend/site/about']],
['label' => 'Admin', 'url' => ['/site/admin']],
];
sifa786
(Ffelaar)
June 1, 2014, 12:26am
2
The only way I have found thus far is to create an alias in the frontend app that is set to the actual URL of the backend app:
Yii::setAlias('backend', 'http://backend.dev');
I then set the label as follows in the frontend:
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => [yii\helpers\Url::to('@backend')]],
['label' => 'Admin', 'url' => ['/site/admin']],
];
Is there a better way to do this?
sifa786:
I want to put a link on my frontend app called ‘Admin’, which links to the \backend\web\index.php file … how should I change the NavBar url?
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['@frontend/site/about']],
['label' => 'Admin', 'url' => ['/site/admin']],
];
Since they are different apps (backend and frontend) - it is difficult to use Yii app methods between 2 apps. The easier approach for menu items is to use absolute url links like you have in your scenario.
You can however design a component at the common level to return such items for both apps.