Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

[solved] [newbie] CHtml:link with an image

$
0
0
Hello,

I have (I hope so) a simple question...
How do I create a link with an image?

The normal way is so:
<?php echo CHtml::link([some HTML], array('view', 'id'=>$data->id)); ?>


The problem is the following:
The pictures I'd like to show are saved on my server, the path is saved in a mySQL-Database.

Here is the structure:
id int(11) auto_increment
picturenumber int(11) -> imagename on the server
gallery int(11) -> FK to another table (at the moment not relevant)
portfolio bool

How the pictures are stored:
server/gallery/[gallery]/[picturenumber].jpg

And now the big question...
What have I to insert in the server/protected/views/gallery/_view.php?

It must be something like this ;)
<?php echo CHtml::link(<img src="gallery/"$data->gallery/th_$data->picturenumber.jpg" alt="$data->picturenumber.jpg" />, array('view', 'id'=>$data->id)); ?>

And the output must be like this:
<a href="server/index.php?r=pictures/view&id=[id]">
  <img src="server/gallery/[$data->gallery]/[$data->picturenumber].jpg" alt="[$data->picturenumber]">
</a>


Thanks in advance! :D

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>