0

在为输出生成的链接编写回显时,我可能制造了一个怪物 :( 我不明白在使用 HtmlHelper 时如何连接所有这些参数。我读了两次关于它的文章,但没有明白。

我的代码是:

echo "<a href=\"/img/filmography/" . $movie['Film']['frameset'] . 
     "_frame_" . $i . ".jpg\"" . "rel=\"lightbox[" . $movie['Film']['id'] . 
     "]\"" . " title=\"\">" 

     . "<img src=\"/img/filmography/thumb/" . $movie['Film']['frameset'] . 
     "_frame_" . $i . ".jpg\"" . "alt=\"pic from " . $movie['Film']['title'] . 
     "\"" . "/></a>";

我想在 HTML 中实现的目标:

   <a href="/img/filmography/movie_frame_1.jpg" rel="lightbox[1]" title="">
        <img src="/img/filmography/thumb/movie_frame_1.jpg" 
             alt="pic from some movie"/>
   </a>
4

2 回答 2

2

我想,这对你有用..

$path = sprintf("/filmography/thumb/%s_frame_%s.jpg", $movie['Film']['frameset'], $i);
echo $this->Html->link($this->Html->image($path, array(    "alt" => "pic from " . $movie['Film']['title'])) , '/img/filmography/'. $movie['Film']['frameset'] . '_frame_' . $i . '.jpg',  array('escape' => false, 'rel' => 'lightbox[' . $movie['Film']['id'] . ']'));
于 2012-07-27T19:11:29.240 回答
0

用这个:-

$frame_thumbnail = "img/filmography/" . $movie['Film']['frameset'] ."_frame_" . $i . ".jpg";
$frame_full = "img/filmography/thumb/" . $movie['Film']['frameset'] . "_frame_" . $i . ".jpg";

$alt= "pic from " . $movie['Film']['title'];
$real = "lightbox[" . $movie['Film']['id'] ."]";


$thumb = $html->image($frame_thumbnail, array('alt'=>$alt));
$full = $html->image($frame_full, array('alt'=>$alt));

echo $this->Html->link($thumb,$full,array('escape' => false, 'rel' =>$real));

或阅读此 htmlHelper 和链接

http://api.cakephp.org/class/html-helper#method-HtmlHelperlink

http://book.cakephp.org/view/1442/link

于 2012-07-27T19:06:30.910 回答