1

I've recently downloaded a script and was working on it on my localhost. The problem is that I never worked or used PHP before, neither CakePHP. All its new to me. I perfectly know HTML, CSS and Javascript (can read/understand PHP). But it's hard to understand CakePHP and how it works. I've been waching and reading books about CakePHP and still don't found how to do this.

The script comes with a menu. I've edited some things to match my requirements but I fail adding tags between the php tags. To understand more, here is the original code:

 
echo $this->Html->link(__('Home'), array('admin'=>false, 'plugin'=>null, 'controller'=>'events', 'action'=>'index'));

And here is what I would really want to do/implement:

<!-- <ul>
    <li><a href="">Home<em class="glyphicon glyphicon-ok-circle"></em></a></li>
    <li><a href="">Users<em class="glyphicon glyphicon-ok-circle"></em></a></li>
    <li><a href="">Profile<em class="glyphicon glyphicon-ok-circle"></em></a></li>
    <li><a href="">Mesages<em class="glyphicon glyphicon-ok-circle"></em></a></li>
</ul> -->

And this is what I made till now:

<ul>echo '<li>';Html->link(__('Home'), array('admin'=>false, 'plugin'=>null, 'controller'=>'events', 'action'=>'index'));echo '</li>';

Output:

<ul><li><a href="">Home</a></li></ul>

Should be: (final result)

<ul><li><a href="">Home<em class="glyphicon glyphicon-ok-circle"></em></a></li></ul>

And here is the problem/issue (don't know how to implement this):

<em class="glyphicon glyphicon-ok-circle"></em>

I've tried to concatenate, but doesn't worked (example):

echo $this->Html->link(__('Home').'<em></em>', array('admin'=>false, 'plugin'=>null, 'controller'=>'events', 'action'=>'index'));

Output (the em tags are output as a plain text, not as html tags):

<a href="">Home<em></em></a>

Any suggestions/hels would be much appreciated. Thank you.

1 Answer 1

2

You need the "escape" property at false to not escape HTML tags

Should be :

<?php echo $this->Html->link(__('Home').'<em></em>', array('admin'=>false, 'plugin'=>null, 'controller'=>'events', 'action'=>'index'), array('escape' => false)); ?>

Cake Cookbook for HTMLHelper: http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html

Look at :

HtmlHelper::link(string $title, mixed $url = null, array $options = array(), string $confirmMessage = false)

(hope this help, sorry for my english)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. That worked like a charm. Im reading that CookBook right now. I'm sure I may need some help in the future, but much thanks anyway.

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.