我正嘗試使用cakephp創建分頁,但它給了我找不到錯誤地址。 未在此服務器上找到請求的地址'/ mygroup/newsfeed/page:2'。在cakephp分頁中找不到請求的地址錯誤
我收到以下錯誤在我的日誌文件
Error: [MissingActionException] Action GroupsController::page:2()
could not be found.
Exception Attributes: array (
'controller' => 'GroupsController',
'action' => 'page:2',
)
請在下面找到我的代碼:
查看:
<?php if($this->params['paging']['NewsFeed']['pageCount'] > 1): ?>
<?php $this->paginator->options(array('url' => array('controller' => 'groups',
'action' => 'newsfeed', 'sluggroup' => $groupdata['Group']['group_slug'])));?>
<div class="paginationbiz">
<ul>
<li class="prevnext disablelink"><?php echo $this->paginator->prev('« Prev',array()); ?></li>
<li><?php echo $this->paginator->numbers(); ?></li>
<li class="prevnext"><?php echo $this->paginator->next('Next »',array()); ?></li>
</ul>
</div>
<?php endif; ?>
routes.php文件
Router::connect('/:sluggroup/:action/*', array('controller' => 'groups',
'action' => 'newsfeed'),array('pass' => array('sluggroup')));
控制器:
$this->paginate = array(
'conditions' => array('NewsFeed.group_id'=>$groupdata['Group']['id'],'NewsFeed.status'=>'A'),
'joins' => array(
array(
'alias' => 'newslikes',
'table' => 'news_feed_likes',
'type' => 'LEFT',
'conditions' => array('newslikes.news_feed_id = NewsFeed.id','newslikes.user_id'=>$this->Auth->user('id'),'newslikes.status'=>'1')
),
),
'fields' => array('IFNULL(newslikes.user_id,0) AS likestatus','NewsFeed.id','NewsFeed.group_id','NewsFeed.posted_message','NewsFeed.event_id','NewsFeed.event_desc','NewsFeed.event_slug','NewsFeed.event_title','NewsFeed.doc_id','NewsFeed.doc_title','NewsFeed.doc_file','NewsFeed.doc_path','NewsFeed.alert_id','NewsFeed.alert_title','NewsFeed.alert_desc','NewsFeed.created','NewsFeed.user_id','NewsFeed.status','NewsFeed.newslike'
,'IFNULL(newslikes.status,0) AS status'),
'order' => array(
'NewsFeed.updated' => 'desc'
),'limit' =>10, 'page'=>1,
);
$this->set('newsfeed', $this->paginate($this->NewsFeed));
感謝您的回答 – user1851420
我已經通過使用此路由解決了此問題Router :: connect('/:sluggroup/newsfeed/*',array('controller'=>'groups','action'=>'newsfeed' ),array('pass'=> array('sluggroup'))); – user1851420