<a rel="float-shadow" class="button float-shadow" href="#">
<article>
<div class="prodct-img">
<img src="<?php echo $imgurl.$row['pimage1'] ?>">
</div>
</article> </a>
To this div how can i give link in Yii
Assuming you want to take the user to www.yoursite.com/controller/action
; if the image fills the div, you could use:
<article>
<div class="prodct-img">
<?php echo CHtml::link(CHtml::image($imgurl.$row['pimage1'],'alt text'),array('controller/action'); ?>
</div>
</article>
Which would create an anchor tag around the image using CHtml::link.
Or if there's more content in the div than just the image you could always attach an onclick event to the div with javascript?
<?php
$navigateTo = Yii::app()->createUrl('/controller/action/');
Yii::app()->getClientScript()->registerScript('globalJs', <<<EOD
$( "#clickable-div" ).click(function() {
location = "$navigateTo";
});
EOD
,CClientScript::POS_END);
?>
<article>
<div class="prodct-img" id="clickable-div">
<?php echo CHtml::image($imgurl.$row['pimage1'],'alt text'); ?>
</div>
</article>
If you really want the div around the whole lot it would probably be easiest to write is as you have rather than use CHtml. Otherwise you'll need to set the content into a variable and set that as the $text
parameter on CHtml::link() which in most cases wouldn't be a good way of doing things.