5

I am trying to use CakePHP HTML Linker for the following code

<li class="iAdd"><a href="add"><span>Add Cuisine</span></a></li>

Since the span tag needs to be inside the a tag. am not able to get the output as need. Any suggestions on how to get it done ?

2 Answers 2

8

Disable the escape option in your link code, like so:

<li class="iAdd">
<?php echo $this->Html->link(
    '<span>Add Cuisine</span>',
    array('action' => 'add'),
    array('escape' => false) // This line will parse rather then output HTML
); ?>
</li>
Sign up to request clarification or add additional context in comments.

Comments

5

you can always use normal html in links:

$this->Html->link('<span>'.h($text).'</span>', array('action'=>'add'), array('escape'=>false));

3 Comments

note the h() if you plan on passing db input into your link then for security purposes (many programmers forget that while using escape=>false)
if the text is static i can use it directly ?
sure - if you know that it doesnt contain any html chars that could mess up your layout (< > " ...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.