doulu2591 2014-01-24 19:44
浏览 28
已采纳

图像作为分色链接在cakephp 2.x中

I have a gallery custom coded using cakePHP. Currently, I'm trying to get the pagination links for next and previous page to appear as images. The links work perfectly as text. In order to output them as simple text, I use the following code:

<?php   
echo $this->Paginator->prev();
echo $this->Paginator->next();      
?>

However, this outputs the links as text saying << Previous and Next >> respectively. I want to replace said output for images I have. I have looked around and found something that replaces the text for the image:

echo $this->paginator->prev($this->html->image('/images/icon_prev.png'), array('escape' => false));

However, it seems to break the link: While the link for the standard previous/next buttons go as:

http://galleryurlhere/albums/view/7/page:2

The new image link outputs them as:

http://galleryurlhere/albums/view/page:2

Thus failing to send the album ID as a variable and therefore breaking the pagination. Can anyone help me with this? I've tried overloading the function with the variable (Which I can access from the code), but that doesn't seem to be working. Any clue what I'm doing wrong?

  • 写回答

1条回答 默认 最新

  • douhui3760 2014-01-28 11:19
    关注

    This does not make much sense but the problem is in how you call the Helper.

    This does NOT work properly

    echo $this->paginator->prev( $this->html->image('/images/icon_prev.png'), array('escape' => false) );
    

    while this DOES: (note the capital "P")

    echo $this->Paginator->prev( $this->html->image('/images/icon_prev.png'), array('escape' => false) );
    

    More details

    It seems like $this->Paginator is not the same object as $this->paginator (spl_object_hash()). Similarly I would use $this->Html and not $this->html as my Html Helper.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计