创建图像链接会创建添加控制器名称的路径

时间:2014-04-29 05:27:01

标签: image cakephp path controller

我正在尝试使用以下结构在cakephp中实现图片库:

echo $this->Html->link(
        $this->Html->image('gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
            array('class'=>'img img-responsive')
        ),
        'gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
            array(
              'class' => 'col-sm-4',
              'escape' => false,
              'data-toggle' => 'lightbox',
              'data-gallery' => 'multiimages',
            )
        );

但上面的脚本会输出HTML

<a href="/nitish/cakem/galleries/gallery/fashion/fashion-photography-guwahati-big-4.jpg" class="col-sm-4" data-toggle="lightbox" data-gallery="multiimages">

<img src="/nitish/cakem/img/gallery/fashion/fashion-photography-guwahati-4.jpg" class="img img-responsive" alt="" />

</a>

正如您在anchor路径中所看到的,添加了额外的galleries目录。如何删除?

注意:galleries是我的控制器名称

1 个答案:

答案 0 :(得分:1)

用斜线描述你的路径:

echo $this->Html->link(
    $this->Html->image('/gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
        array('class'=>'img img-responsive')
    ),
    '/gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
    array(
      'class' => 'col-sm-4',
      'escape' => false,
      'data-toggle' => 'lightbox',
      'data-gallery' => 'multiimages',
    )
);