A
A
Alexey102019-02-11 15:44:54
Yii
Alexey10, 2019-02-11 15:44:54

How to add id to menu links?

Guys, hello everyone I
register the menu on the site

<div class="c-header__bottom">
        <?php

        $items = Menu::getTopMenuItems();
        if(count($items)):
            ?>
            <nav class="c-navbar c-navbar--fixed@md">


                <?php
                foreach($items as $i => $item) {
                    $item['linkOptions'] = array('class' => 'c-navbar__link');
                    
                    if(isset($item['items']) and count($item['items'])) {
                        $item['url'] = '#';
                        $item['link'] = '#';
                    }
                    $items[$i] = $item;
                }

            


                $this->widget(
                    'Menu',
                    array(
                        'items' => $items,
                        'id' => 'menu-list',
                        'htmlOptions' => array('class' => 'o-list-bare c-navbar__menu'),
                        'itemCssClass' => '',
                    )
                );
                ?>

                <div class="c-topbar__search">
                    <form class="c-search" action="/shop/search" method="get">
                        <input class="c-search__input" type="text" name="search" placeholder="Поиск по сайту">
                        <button class="c-search__submit" type="submit"><span class="u-hidden-visually">Найти</span>
                            <svg class="c-search__icon">
                                <use xlink:href="#icon-search"></use>
                            </svg>
                        </button>
                    </form>
                </div>
            </nav>
        <? endif; ?>
    </div>

how do i add after each link in menu id #page-content ?
to output something like /about#page-content , /main#page-content , etc.
Thank you all for your help ))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2019-02-11
@kawabanga

It is not clear what you have inside, unreadable code.
In general, the link is formed with an anchor if you add
['view','param1'=>'value','#'=>'jakorb']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question