Adding HTML to a link in CakePHP3

Adding HTML to a link in CakePHP3

Here's how to add HTML to a Html->Link:

We want to add an icon to the link: <i class="fa fa-user"></i>
Note the ['escape'=>'false'] is a separate array.

Method 1: Link Builder

$this->Html->link('<i class="fa fa-user"></i> Client Projects', 
   ['controller'=>'ClientProjects', 'action'=>'index'], 
   ['escape'=>false]
);

 

Method 2: URL Builder

<a href="<?php echo $this->Url->build(array('controller'=>'clients','action'=>'index')); ?>"><i class="fa fa-address-book"></i> Clients <b class="caret"> </b></a>      

Share this Post