10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【CakePHP2.3】画像付リンクの指定方法(Htmlヘルパー)

Posted at

#画像リンクをHTMLヘルパーで生成

つまり、以下のようなHTMLをHTMLヘルパーで
出力したい場合、どう記述するか?

sample.html
<a href="/user/regist">
<img src="/img/user/button01.png" alt="">
</a>

2パターンでやってみた。

##①linkベース

sample.ctp
<?php echo $this->Html->link($this->Html->image('user/button01.png'),array('controller'=>'user','action'=>'regist'),array('escape'=>false));?>

##②imageベース

sample.ctp
<?php echo $this->Html->image('user/button01.png',array('url'=>array('controller'=>'user','action'=>'regist')));?>

##結論
ヘルパー使わきゃよくね?

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?