0

I have the following Link Format which i want to display using Cakephp HTML helper

<a href="product_n1_details.html" title="" class="view_image"> 
 <img src="images/slider/1n.jpg" alt="">
 <div class="link_overlay icon-search"></div>
</a>

What i have tried?

<?php echo $this->Html->link($this->Html->image('products/'.$pro['Product']['display_photo']."<div class=\'link_overlay icon-search\'></div>", array('alt' => $pro['Product']['name'])), array('controller' => 'products', 'action' => 'view', $pro['Product']['id']), array('escape' => false, 'class' => 'view_image') ); ?>

enter image description here

scrowler
  • 24,273
  • 9
  • 60
  • 92
Harsha M V
  • 54,075
  • 125
  • 354
  • 529

2 Answers2

2

The image helper returns the entire <img> tag, so put the div code after your image helper call (spaced out for clarity):

echo $this->Html->link(
    $this->Html->image(
        'products/'.$pro['Product']['display_photo'],
        array(
            'alt' => $pro['Product']['name']
        )
    ) . "<div class='link_overlay icon-search'></div>", // put it here!
    array(
        'controller' => 'products',
        'action' => 'view',
        $pro['Product']['id']
    ),
    array(
        'escape' => false,
        'class' => 'view_image'
    )
);
scrowler
  • 24,273
  • 9
  • 60
  • 92
1

scrowler is correct.

All Html helper functions return strings so if you want to make it a little cleaner for yourself you could do this

$image = $this->Html->image( . . . );
$div   = $this->Html->tag( 'div', ... );

Then finally

echo $this->Html->link( $image . $div, ... );

Hope that helps.

GatorGuy023
  • 297
  • 2
  • 3
  • 11