I
I
Igor Lavrov2018-06-13 14:32:32
Yii
Igor Lavrov, 2018-06-13 14:32:32

How to make a menu with anchors and links?

How to make a menu with anchors and links so that all buttons work.
My menu sections are:

$menuItems = [
        ['label' => 'Портфолио', 'url' => '#portfolio'],
        ['label' => 'Как я работаю?', 'url' => '#howiwork'],
        ['label' => 'Цены', 'url' => '#price'],
        ['label' => 'Сертификаты', 'url' => '#сertificates'],
        ['label' => 'Контакты', 'url' => ['/site/contact']],
    ];

In fact, everything is simple. I made a smooth transition of anchors to js.
And if you do it like this, then everything works out, the menu is clicked ... but the smooth scrolling is gone. so it doesn't suit me.
$menuItems = [
        ['label' => 'Портфолио', 'url' => '/#portfolio'],
        ['label' => 'Как я работаю?', 'url' => '/#howiwork'],
        ['label' => 'Цены', 'url' => '/#price'],
        ['label' => 'Сертификаты', 'url' => '/#сertificates'],
        ['label' => 'Контакты', 'url' => ['/site/contact']],
    ];

You need to do it without "/" and so that the menu understands how to go to the main one and to the desired block.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-06-13
@webinar

[
  'label' => 'Как я работаю?', 
  'url' =>
             [
                'controller/action', 
                'someParam'=>'someValue', 
                '#' =>'howiwork'
             ],
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question