Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html markup in cakephp's $html->link, eg. $html->link('<span>Hey</span>')?

Tags:

cakephp

I have this block of code in a cakephp .ctp file:

<h1>
    <?php echo $this->Html->link('Hello <span>Stack Overflow</span>',
        array('controller'=>'pages', 'action'=>'home'));  ?>
</h1>

But instead of the html being formatted, I'm seeing it literally:

<h1><a href="/rrweb/www/hub/pages/home">
Hello &lt;span&gt;Stack Overflow&lt;/span&gt;</a></h1> 

Any idea's?

Thanks!

like image 416
Waldo Bronchart Avatar asked Nov 29 '22 11:11

Waldo Bronchart


2 Answers

You need to disable HTML entity conversion:

echo $this->Html->link(
    'Hello <span>Stack Overflow</span>',
    array('controller'=>'pages', 'action'=>'home'),
    array('escape' => FALSE)
);
like image 72
Stephen Avatar answered Dec 04 '22 09:12

Stephen


or

echo $this->Html->link('Hello', array('controller'=>'pages', 'action'=>'home')).' '.$this->Html->tag('span', $this->Html->link('Stack Overflow', array('controller'=>'pages', 'action'=>'home')), array()); 
like image 34
jplfl Avatar answered Dec 04 '22 10:12

jplfl