Anyone have an answer to this problem?

Thanks

On Apr 7, 7:19 pm, "Juan Luis Baptiste" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I'm trying to make a view element and reuse it in various  views. The
> element uses the pagination helper, the problem is that the element
> can't see the paginator helper object:
>
> : Undefined variable: paginator [APP/views/elements/servers.ctp, line 7]
>
> If I add the helper to the "uses" variable of the controller which
> calls the action that includes the element on its view, then the
> helper is found but I get these errors:
>
> Warning (2): array_merge() [function.array-merge]: Argument #1 is not
> an array [CORE/cake/libs/view/helpers/paginator.php, line 139]
>
> The code of my element is something like the the following:
>
> $servers = $this->requestAction('servers/index/');
> ?>
>         <table cellpadding="0" cellspacing="0">
>         <tr>
>                 <th><?= $paginator->sort('Server Name', 'name');?></th>
>                 <th><?= $paginator->sort('IP Address', 'ip_address');?></th>
>         </tr>
>         <?php foreach ($servers as $server): ?>
>         <tr>
>                 <td><?= $server['Server']['name']; ?></td>
>                 <td><?= $server['Server']['ip_address']; ?></td>
>         </tr>
>         <?php endforeach; ?>
>         </table>
>         <?php $paginate = $paginator->prev('<< Previous ', null, null);?>
>         <?php $paginate .= $paginator->next(' Next >>', null, null);?>
>         <?php $paginate .=  '<br/>'.$paginator->counter(); ?>
>         <?=$html->div(null,$paginate, array('align' => 'center')); ?>
>
> on the view that includes it:
>
> echo $this->renderElement('servers');
>
> and the controller action:
>
> function index($id = null) {
>   $servers = $this->paginate('Server');
>   $this->set(compact('servers'));                                    
>   if(isset($this->params['requested'])) {
>      return $servers;
>   }
>
> }
>
> So how is the propper way to use the pagination helper on a view element ?
>
> Thanks.
> --
> Juan Luis Baptiste

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to