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 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动
  • ¥15 大一C语言期末考试,求帮助🙏🙏
  • ¥15 ch340驱动未分配COM
  • ¥15 Converting circular structure to JSON
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader