Ty Yt
Ty Yt

Reputation: 466

Add icon to a link cakephp 2

I'd like to add a icon <i> tag to a Cakephp link. Here is my code :

<?= $this->Html->link($this->Html->tag('i', '', array('class' => 'fa fa-shopping-cart')).'Cart', array('controller' => 'shop', 'action' => 'cart')) ?>

This line generates :

<a href="/cakephp-shopping-cart/shop/cart">&lt;i class="fa fa-shopping-cart"&gt;&lt;/i&gt;Cart</a>

Why < is replaced by its hexa value? My charset is UTF-8.

Thanks!

Upvotes: 1

Views: 4809

Answers (2)

Praveen Kumar Joshi
Praveen Kumar Joshi

Reputation: 21

Html->link($this->Html->tag('i', '',['class' => 'fa fa-shopping-cart']).'Cart',['controller' => 'shop', 'action' => 'cart'], ['escape' => false]); ?>

Upvotes: 0

marian0
marian0

Reputation: 3327

Add option 'escape' set to false:

<?= $this->Html->link($this->Html->tag('i', '', array('class' => 'fa fa-shopping-cart')).'Cart', array('controller' => 'shop', 'action' => 'cart'), array('escape' => false)) ?>

Documentation page about HtmlHelper.

Upvotes: 9

Related Questions