A
A
agent11562017-01-29 18:41:21
Yii
agent1156, 2017-01-29 18:41:21

How to link to homepage in navbar in yii2?

$menuItems = [
        ['label' => 'Сайт', 'url' =>  ['/@frontend/web/site/index']],   <---   Как перейти из backend во фронтенд ?
        ['label' => 'Статичные страницы', 'url' =>  ['/staticpages/index']],
        ['label' => 'Лента' , 'url' => ['alaniatape/index']],
        ['label' => 'Картинки', 'url' => ['img/index']],
    ];

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Anton Natarov, 2017-01-29
@HanDroid

I'm not sure that you need to specify Web after the frontend
alias . You can also go to the main one in this way
. In general, you can do it in the same way for the backend.
Toaster

M
Maxim Timofeev, 2017-01-29
@webinar

['label' => 'Главная', 'url' => '/'],
depending on the settings of the url manager, it may work like this:
where site is the name of the controller, and index is the action of the main page

M
MrAmid1987, 2018-07-05
@MrAmid1987

['label' => 'Home', 'url' => ['/..']],

I
Igor Vasiliev, 2018-09-17
@Isolution666

There are several ways to get to the right place for sure:
Effective:
find out the data on a specific page:

<?= __FILE__; // абсолютный путь ?>
<?=$this->context->module->id; // какой модуль используется ?>
<?=Yii::$app->controller->action->id; // имя экшена ?>

and display the corresponding link in the menu, or use routers:
<?=Html::a('Главная', Url::toRoute('/web/page/index'));?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question