Harsha M V
Harsha M V

Reputation: 54949

Image Link with DIV tag

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

Upvotes: 0

Views: 936

Answers (2)

GatorGuy023
GatorGuy023

Reputation: 297

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.

Upvotes: 1

scrowler
scrowler

Reputation: 24406

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'
    )
);

Upvotes: 2

Related Questions