Uso de paginate

edited octubre 2008 in Principiantes
Estoy haciendo pruebas con paginate, en el controlador tengo puesto esto:
$this->page = $this->Bandas­>paginate("page: $page", 'per_page: 7');

y en la vista:
<?php foreach($page­>items as $p): ?>
<tr>
      <td><?php echo $p­>id ?></td>
      <td><?php echo h($p­>nombre) ?></td>
</tr>
<?php endforeach; ?>

Me haparece siguiente error:

Notice: Use of undefined constant items - assumed 'items' in /home/salva/www/elmusical/apps/default/views/pruebas/index.phtml on line 1

Notice: Undefined variable: page­ in /home/salva/www/elmusical/apps/default/views/pruebas/index.phtml on line 1

Warning: Invalid argument supplied for foreach() in /home/salva/www/elmusical/apps/default/views/pruebas/index.phtml on line 1

Comentarios

  • edited 11:24
    tienes mal el codigo de la vista.
    cambia esto
    <?php foreach($page­>items as $p): ?>
    <tr>
          <td><?php echo $p­>id ?></td>
          <td><?php echo h($p­>nombre) ?></td>
    </tr>
    <?php endforeach; ?>
    

    por esto
    <?php foreach($page­->items as $p): ?>
    <tr>
          <td><?php echo $p­->id ?></td>
          <td><?php echo h($p­->nombre) ?></td>
    </tr>
    <?php endforeach; ?>
    


    te falto el gion, parece que copiastes la funcion del pdf y no te pegó el
    gion. jajjajaj

    no te preocupes a mi = me pasa, debes revisar bien el códigp cuando lo copies.

    en el controller = le falta el gion
  • edited 11:24
    tenias razon, ese era un error pero al subsanarlo, me aparece este:

    Notice: Trying to get property of non-object in /home/www/elmusical/apps/default/views/pruebas/index.phtml on line 1

    Warning: Invalid argument supplied for foreach() in /home/www/elmusical/apps/default/views/pruebas/index.phtml on line 1
  • Seguro hiciste un copy/paste del código sin revisar... y no te diste cuenta,
    que esta mal escrito (fijate en la parte negrita)
    <?php foreach($page­>items as $p): ?>

    Deberia ser...
    <?php foreach($page­->items as $p): ?>
Sign In or Register to comment.