I'm trying to code an element that shows the comments about a certain
item, but when I'm using the paginator helper i get a "Fatal error:
Call to a member function numbers() on a non-object in[...]" message.
Searching the group i found that some users had the same problem, but
never received a valid answer, so... let's try again.
The code:
CONTROLLER:
class ItemsCommentsController extends AppController {
function index($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}
$comments = $this->paginate('ItemComment', array
('ItemComment.item_id =' => $id));
if(isset($this->params['requested'])) { return $comments;}
$this->set('comments', $comments);
}
}
VIEW:
echo $this->element('item_comments',array('id'=>$item['Item']['id']));
ELEMENT:
<?php $comments = $this->requestAction('items/get_comments/'.$id); ?>
<?php
echo $paginator->numbers(); ?>
echo $paginator->prev('« Previous ', null, null, array('class' =>
'disabled'));
echo $paginator->next(' Next »', null, null, array('class' =>
'disabled'));
foreach ($comments as $comment){
echo '<br />User: '.$comment['User']['username']).'<br />';
echo $comment['ItemComment']['content'].'<br />';
}
?>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---