I'm using cakephp 2.3.0. I searched in the manual for quite awhile, but I haven't found the answer. I'm trying to use $this->Html->link, along with $this->Html->image. I'm trying to create the ability to click on an image. Any ideas as to why the ascii rendering of quotes is being generated?
Here is my snippet codeset in my view ctp:
echo $this->html->tableCells(
array(
array(
array (
$this->Html->link($myActivity['Activity']['name'], array('controller' => 'users', 'action' => 'edit'), array('title' => '')),
array('align' => 'left')),
array ($myActivity['Activity']['status'], array('align' => 'left')),
array ($myActivity['Activity']['any_messages'], array('align' => 'left')),
$date2,
array ($this->Html->link(
$this->Html->image('pencil.jpg', array('alt' => 'Edit', 'border' => '0', 'width' => '25')),
array('controller' => 'users', 'action' => 'add'), array('title' => ''))
),
$this->Html->image('trashcan.jpg', array('alt' => 'Delete', 'border' => '0', 'width' => '25')),
$this->Html->image('copy.png', array('alt' => 'Copy', 'border' => '0', 'width' => '25')),
)
)
);
Below is the actual HTML result of the code above. As you can see, the generated HTML is showing ascii version of quotes (") and '<' and '>':
<tr>
<td align="left">
<a href="/activities/index.php/users/add" title="">Running</a>
</td>
<td align="left">Live</td>
<td align="left">no</td>
<td>02/18/13</td>
<td>
<a href="/activities/index.php/users/edit" title=""><img src="/activities/app/webroot/img/pencil.jpg" alt="Edit" border="0" width="25" /></a>
</td>
<td>
<img src="/activities/app/webroot/img/trashcan.jpg" alt="Delete" border="0" width="25">
</td>
</tr>
Below is what I would expect the HTML to look like:
<tr>
<td align="left">
<a href="/activities/index.php/users/add" title="">Running</a>
</td>
<td align="left">Live</td>
<td align="left">no</td>
<td>02/18/13</td>
<td>
<a href="/activities/index.php/users/edit" title="">
<img src="/activities/app/webroot/img/pencil.jpg" alt="Edit" border="0" width="25"></a>
</td>
<td>
<img src="/activities/app/webroot/img/trashcan.jpg" alt="Delete" border="0" width="25">
</td>
</tr>
echo $this->Html->image('imagename',array('alt'=>'myimage','class'=>'img-responsive'));
This is normal image without any link, now to wrap it with link tag use
echo $this->Html->link($this->Html->image('imagename',array('alt'=>'myimage', 'title'=>'myimage','class'=>'img-responsive')), [
'controller' => 'controllerName',
'action' => 'actionName',
'id' => $value['id'], //if any parameters are passed
],['escape' => false]);
Similarly you can assign the image tag to a variable and use it
$myImageVar = $this->Html->image('imagename',array('alt'=>'myimage','class'=>'img-responsive'));
echo $this->Html->link($myImageVar, [
'controller' => 'controllerName',
'action' => 'actionName',
'id' => $value['id'], //if any parameters are passed
],['escape' => false]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With