我正在使用 CakePHP 2.3 开发一个应用程序并且遇到了分页问题。当我单击任何分页链接时,我在此服务器上找不到 /cab/ServiceDirectory/refine/page:2 (或任何链接)。如果我去 /cab/ServiceDirectory/refine 我看到分页链接显示应该有 5 页。如果我从控制器和视图中删除分页代码,我会看到我应该看到的所有结果。
在我的 ServiceDirectoryResultsController 我有
public function index() {
$this->ServiceLocation->recursive=0;
}
public function refine ($id=null) (
// All my code to get the ServiceLocations from the DB
$this->paginate->array(
'conditions' => array('ServiceLocation.state' => $states[$state], 'ServiceLocation.solution_categories' => $active_cat),
'limit' => 8,
);
$results = $this->paginate('ServiceLocation');
$this->set('serviceLocation' ,$results);
}
在我看来我有
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
<?php foreach ($serviceLocation as $Location): ?>
// I echo a few things from the $Location array
<?php endforeach; ?>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
如果没有分页并使用查找全部并将其发送到视图,我会看到我期望的 40 个结果。
随着分页,我看到分页链接,如果我将鼠标悬停在它们上面,我会看到我的网址 /cab/ServiceDirectoryResults/refine/page:2 或 page:3 或 page:4 或 page:5
如果我单击其中任何一个带有 :pageX 的链接,我会收到错误消息
错误:请求的地址“/cab/ServiceDirectoryResults/refine/page:2 在此服务器上找不到”
我已经阅读了大量有关 CakePHP 分页的内容,但找不到任何导致这种行为的原因。任何人都可以提出一个原因或可能的解决方案或可遵循的路径来调试此错误吗?
问候
理查德
我检查了错误级别,它已经设置为 2 级
这是错误日志中的最后一个条目
2013-05-22 17:09:28 Error: [NotFoundException] Not Found
Request URL: /cab/ServiceDirectoryResults/refine/page:2
Stack Trace:
#0 /var/www/html/cab/lib/Cake/Controller/Controller.php(1074): PaginatorComponent->paginate('ServiceLocation', Array, Array)
#1 /var/www/html/cab/app/Controller/ServiceDirectoryResultsController.php(381): Controller->paginate('ServiceLocation')
#2 [internal function]: ServiceDirectoryResultsController->refine()
#3 /var/www/html/cab/lib/Cake/Controller/Controller.php(486): ReflectionMethod->invokeArgs(Object(ServiceDirectoryResultsController), Array)
#4 /var/www/html/cab/lib/Cake/Routing/Dispatcher.php(187): Controller->invokeAction(Object(CakeRequest))
#5 /var/www/html/cab/lib/Cake/Routing/Dispatcher.php(162): Dispatcher->_invoke(Object(ServiceDirectoryResultsController), Object(CakeRequest), Object(CakeResponse))
#6 /var/www/html/cab/app/webroot/index.php(109): Dispatcher- >dispatch(Object(CakeRequest), Object(CakeResponse))
#7 {main}
希望有帮助