0

How can I get this in Yii framework using Chtml::link

<a href="#" title="Movie 1" class="search-movie"><img alt="Movie 1" src="../../images/1.jpg"><p>Movie 1</p></a>

When I did this,

<?php $imghtml=CHtml::image('../../images/1.jpg');
echo CHtml::link($imghtml, array('moviepage/index'),array('class'=>'search-movie', 'title'=>'Movie 1'));?>

I only got

<a href="#" title="Movie 1" class="search-movie"><img alt="Movie 1" src="../../images/1.jpg"></a>

2 Answers 2

3

You need to include the markup for the caption when you generate the link:

<?php 
    $imghtml=CHtml::image('../../images/1.jpg');
    $caption = CHtml::tag('p', array(), 'Movie 1');
    echo CHtml::link("{$imghtml}{$caption}", array('moviepage/index'), array('class'=>'search-movie', 'title'=>'Movie 1'));
?>
0
2

Like so:

<?php $imghtml=CHtml::image('../../images/1.jpg');
echo CHtml::link("$imghtml<p>Move 1</p>", array('moviepage/index'),array('class'=>'search-movie', 'title'=>'Movie 1'));?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.