CHtml :: link () with internal content

Is there a way to generate this HTML output using the Yii method of CHTML :: link ()?

<a href="localhost/somecontroller/someaction" class="foo"><i class="bar"></i>My awesome link</a>

I need some nested tag in the anchor tag and cannot figure out how to insert it. CHTML: link () is not preferred over other methods. If you know how to implement this with CMenu, it will also be great.

+3
source share
2 answers

Ok, I only found one solution. This eludes the "" character in the first parameter of the link method. I know this is so ugly, but I can handle it.

<?php echo CHtml::link('<i class=\'icon s\'></i>Foo',array('/site/index'), array('class'=>'hover')); ?>
+1
source

Maybe you can try this.

<?php echo CHtml::link(CHtml::tag('i', array('class'=>'bar'), 'My awesome link'), array('somecontroller/someaction'), array('class'=>'foo')); ?>

+5
source

Source: https://habr.com/ru/post/1784407/


All Articles