Answer the question
In order to leave comments, you need to log in
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:
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
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.
yii cannot add classes to links
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']],
],
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question