2010-02-03 80 views
0

比方說,我有分頁此頁:CakePHP的分頁問題,​​下一首/上

本地主機/ FR /用戶/指數/頁:1

我看到第1頁正確的結果基礎上如何我已經在我的控制器中定義了paginate var。但是,當我點擊下一個按鈕時,網址更改爲頁面:2,但結果不變,並且與頁面:1相同,頁面:3,頁面:4等等相同...

如果我第一次對列進行排序,我們說用戶名,那麼我可以使用上一個/下一個鏈接,沒有任何問題,每個頁面上的數據都會發生變化。

我能想到的唯一的事情可能會導致我的問題是,我用我的網址語言PARAM,但我不知道如何解決這一問題...我目前使用蛋糕1.2

。 5。我也嘗試了1.3測試版,結果相同。

好了,所以這是我的用戶控制器代碼:

var $paginate = array('limit'=>'5'); 
function index() { 
$this->User->recursive = 0; 
$this->set('users', $this->paginate()); 
} 

我使用teknoid教程語言切換:

URL-based language switching...

語言PARAM通過app_helper.php

function url($url = null, $full = false) { 
    if(!isset($url['language']) && isset($this->params['language'])) { 
     $url['language'] = $this->params['language']; 
    }  

    return parent::url($url, $full); 
} 
添加

和使用方法完成語言切換在app_controller.php:

function _setLanguage() { 

    if ($this->Cookie->read('lang') && !$this->Session->check('Config.language')) { 
     $this->Session->write('Config.language', $this->Cookie->read('lang')); 
    } 
    else if (isset($this->params['language']) && ($this->params['language'] 
     != $this->Session->read('Config.language'))) {  

     $this->Session->write('Config.language', $this->params['language']); 
     $this->Cookie->write('lang', $this->params['language'], null, '20 days'); 
    } 
} 

SOLUTION:

設立雅虎老闆網站,注意到,尋呼是完美的工作後,我更加緊密地在我的代碼看了一下,發現這個問題是我的routes.php文件裏。

我有這樣的:

Router::connect('/news', array('controller'=>'news', 'action'=>'index')); 

Router::connect('/:language/news', array('controller'=>'news', 'action'=>'index'), array('language'=>'[a-z]{2}')); 

我修改它像這樣採取一切PARAMS:

Router::connect('/news/*', etc... 

Router::connect('/:language/news/*', etc... 
+0

有些代碼會有幫助,特別是'UsersController :: index()'動作,或許還有一些關於如何執行語言參數的細節。 – deceze 2010-02-04 01:47:42

回答

0

顯示我們的控制器代碼視圖代碼和一些示例網址。過去我也遇到過類似的問題,但是如果你不給我們更多的信息,沒有人能幫上忙。

0
Even i faced the similar problem 

**Solution** 

I closely checked all my code and after trial and errors i was able to find the solution 

First the cause: I was doing a order by 
$this->paginate = array(
      'limit' => 20, 
      'order' => array('Test.aws_id' => 'asc'), 
      'conditions' => $condition_options 
     ); 

The above code was returning first page result across all pages. 

After a while i closely checked everything and the result set. 
The resultset was returning me **capital AWS_ID** and i was doing my ordering on aws_id after changing it to caps my code was working 

Hope this helps someone