home.ctp 中的分页不可点击数据

Pagination in home.ctp not clickable data

home.ctp

<?php 
    echo $this->element('distromob/featured');
?> 

WebsitesController.php

<?php
    class WebsitesController extends AppController {   
    public $components = array('Paginator'); 
    public function index(){
        $images = $this->paginate('Website');
        if (isset($this->params['requested'])) {
            return $images;
        } else {
            $this->set('images', $images);
        }
    }

featured.ctp

<?php 
 $images = $this->requestAction('/Websites/index');
?>
   <ul>
          <?php     
          foreach($images as $image): ?>
          <?php $domain =  $image['Website']['domain'];?>
             <li><?php echo $this->Html->image('websites/' . $image['Website']['image'],array('width'=>'234px','height' =>'208px','class' => 'random')); 
             ?>
             </li>
             <?php endforeach;?>
         </ul>
     <?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?> 
        <?php $this->Paginator->counter(); ?>
        <?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>

AppController.php

class AppController extends Controller {
public function beforeFilter(){
    $this->Paginator->settings=array(
              'limit'=>4
       );

  }
}

我是 cakephp 的新手,我在网上找到了一些教程,但它似乎不符合我的需要。我的问题是,为什么上一个和下一个分页数据不能点击,分页数据似乎是基于我设置的限制

public function beforeFilter(){
    $this->Paginator->settings=array(
              'limit'=>4
       );

  }

每当我更改限制时它也会显示数据但我无法单击下一个和上一个

尝试将 ->counter() 替换为 ->numbers() 以查看是否有任何页码

使分页数据在元素中可用,即 $this->params['paging']

//index method
 if ($this->params['requested'])
    return array('images'=>$this->paginate('WebSite'), 'paging' => $this->params['paging']);

$this->set('images', $this->paginate('WebSite') );

然后在您的 home.ctp 中执行此操作

$images = $this->requestAction(array('controller'=>'websites','action'=>'index'));  

// if the 'paging' variable is populated, merge it with the already present paging variable in $this->params. This will make sure the PaginatorHelper works
if(!isset($this->params['paging'])) $this->params['paging'] = array();
$this->params['paging'] = Hash::merge( $this->params['paging'] , $images['paging'] );