A
A
artekha2016-08-06 12:42:19
Yii
artekha, 2016-08-06 12:42:19

How to add class for link via yii framework?

I myself am a front-end developer, when I did the layout in the header, I set classes for links. On this site:
polomato.ru (you need to make the screen smaller than 1200px in width), you can see that the last two menu items do not include icons. The backend guy explained this by saying that yii cannot add classes to links. The first two menu items are displayed normally, because it's just layout, but the second ones are made using yii:
64c853b6fb0640629ba9269102eac2a4.png
Question: how can I assign classes to the necessary links using yii?
PS Of course, I can do this through js - after loading the page, look for these links and add classes to them, but this is already a bicycle, and a stupid one at that.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2016-08-06
@bitver

Learn to Google with Toaster.
We see "options: array, optional, the HTML attributes for the menu container tag."
About a miracle, we send your backend worker to hell.

M
Maxim Timofeev, 2016-08-06
@webinar

yii cannot add classes to links

nonsense
here is the docs:
www.yiiframework.com/doc-2.0/yii-widgets-menu.html
Here is an example:
echo Menu::widget([
    'items' => [
        ['label' => 'Home', 'url' => ['site/index'],'template'=>'<a href="{url}" class="MYclass">{label}</a>'],
       ['label' => 'Home', 'url' => ['site/index'],'options'=>['class'=>'MYCLASS']],
    ],
]);

Drive this specialist in the neck

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question