2013-10-14 3 views
2

Я загружаю всех своих пользователей и показываю их в списке и разбиении на страницы в CakePhp. Но почему он дает мне
Ошибка: произошла внутренняя ошибка. и под трассировки стека строкуcakephp pagination говорит Ошибка: произошла внутренняя ошибка

$data = $this->Paginator->paginate('User'); выделен.

UserhomeController.php

<?php 

App::uses('AppController', 'Controller'); 

class UserhomeController extends AppController { 

    public $components = array('Paginator', 'RequestHandler'); 
    public $helpers = array('Js', 'Paginator'); 
    public $paginate = array(
     'fields' => array('User.id', 'User.email'), 
     'limit' => 25, 
     'order' => array(
      'User.email' => 'asc' 
     ) 
    ); 

    public function index() { 
     $this->Paginator->settings = $this->paginate; 

     // similar to findAll(), but fetches paged results 
     $data = $this->Paginator->paginate('User'); 
     $this->set('user', $data); 
    } 

} 

домашний каталог/index.ctp

<?php 
    $this->Paginator->options(array(
     'update' => '#content', 
     'evalScripts' => true 
    )); 
    ?> 
    <div class="container bottom_padding background_color_E8E3D7 height_full padding_top box_shadow"> 
     <table class="table table-striped background_color_eee"> 
      <!-- Here is where we loop through our $users array, printing out post info --> 

      <?php foreach ($data as $user): ?> 
       <tr> 
        <td><?php echo $user['User']['id']; ?></td> 
        <td> 
         <?php echo $this->Html->link($user['User']['title'], array('controller' => 'users', 'action' => 'view', $user['User']['id'])); 
         ?> 
        </td> 
        <td><?php echo $user['User']['email']; ?></td> 
       </tr> 
      <?php endforeach; ?> 
      <?php unset($user); ?> 
     </table> 
     <ul class="pagination"> 
      <?php 
      echo $this->Paginator->prev(__('<<'), array('tag' => 'li'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a')); 
      echo $this->Paginator->numbers(array('separator' => '', 'currentTag' => 'a', 'currentClass' => 'active', 'tag' => 'li', 'first' => 1)); 
      echo $this->Paginator->next(__('>>'), array('tag' => 'li', 'currentClass' => 'disabled'), null, array('tag' => 'li', 'class' => 'disabled', 'disabledTag' => 'a')); 
      ?> 
     </ul> 
     <br/> 
     <?php 
     echo $this->Paginator->counter(
       'Page {:page} of {:pages}, showing {:current} records out of 
     {:count} total, starting on record {:start}, ending on {:end}' 
     ); 
     ?> 

    </div> 
    <?php echo $this->Js->writeBuffer(); ?> 
+0

Вы ссылаетесь модель контроллер ничего не знаетоколо – AD7six

+0

извините, не могли бы вы объяснить. где вы указываете ошибку? –

ответ

10

Добавить public $uses = array('User'); к контроллеру

+2

Спасибо. Торт должен дать вам лучшее сообщение об ошибке для этого. – Jonathan

-1
$data = $this->paginate('User'); 
+0

Вы уверены, что эта проблема решит? это не сработает –

Смежные вопросы