简体   繁体   中英

cakephp, how can I add a class to the url instead of the image

I wonder what is the most cakey way to do this. When I do:

echo $this->Html->image('uploadimage.gif', array('alt'=>'Upload Image', 'class'=>'nyroModal', 'url'=>'#test'));

It outputs:

<a href="#test"><img src="/img/uploadimage.gif" alt="Upload Image" class="nyroModal" /></a>

I need it to be:

<a href="#test" class="nyroModal"><img src="/img/uploadimage.gif" alt="Upload Image"/></a>

IE the class is applied to the link rather than the image. How can I do that?

thanks :)

I have never used cakePHP but for what I read online instead of giving a url to the image you can do it the other way around, create a link and pass an image, the result should be something like this:

<?php 
echo $this->Html->link(
    $this->Html->image("uploadimage.gif", array("alt" => "Upload Image")),
    "#test",
    array("escape" => "false", "class" => "nyroModal")
);
?>

For more info on link you can go here: http://book.cakephp.org/view/1442/link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM