I've discovered the view method renderElement, that has a parameter
called loadHelpers, false but default, that looked good.

But it doesn't work. The paginator helper isn't loaded and I'm getting
the same odd undefined indexes notices.

The renderElement method isn't properly explained neither in the doc
or the api, so I don't know if it's useful, deprecated or whatever.

If i can't use the paginator inside an element, I think is far away
from the shining proclamed in the doc :(


On Jan 30, 11:54 am, Xoubaman <xouba...@gmail.com> wrote:
> Some progress: adding thepaginatorhelper to the helpers array avoid
> the "call to a memeber function in a non-object", but thepaginator
> doesn't paginate anything. In each helper call an undefined index
> error is shown.
>
> Notice (8): Undefined index:  pageCount [CORE\cake\libs\view\helpers
> \paginator.php, line 476]
> Notice (8): Undefined index:  count [CORE\cake\libs\view\helpers
> \paginator.php, line 416]
> ...
>
> Any idea?
>
> Note that thepaginatorhelper must be added to the items controller,
> not the item_comments controller.
>
> On Jan 30, 1:10 am, "dr. Hannibal Lecter" <lecter...@gmail.com> wrote:
>
> > This is just a wild guess, but perhaps it is not applied when you're
> > using requestAction()? It is (if I understand correctly) a separate
> > request as far as cake is concerned.
>
> > Try adding thepaginatormanually in your controller, and if that
> > doesn't work maybe someone else will offer more help.
>
> > On Jan 29, 10:06 pm, Xoubaman <xouba...@gmail.com> wrote:
>
> > > I edited some code to make it more readable in the group, looks like
> > > that is a misstip. The requestAction works fine, in fact if I comment
> > > all $paginatormentions the foreach shows the expected results.
>
> > > The doc reads that setting var $paginate and using the method paginate
> > > () automatically adds the PaginationHelper.
>
> > > On Jan 29, 8:50 pm, "dr. Hannibal Lecter" <lecter...@gmail.com> wrote:
>
> > > > Well, maybe you didn't include the PaginatorHelper in your app.
>
> > > > Other thing which seems odd to me is that your controller is
> > > > "ItemsComments", but in yourelementyou're calling 
> > > > $this->requestAction('items/get_comments/'.$id). Is 
> > > > 'items/get_comments/'
>
> > > > properly mapped to ItemsComments::index()?
>
> > > > On Jan 29, 7:22 pm, Xoubaman <xouba...@gmail.com> wrote:
>
> > > > > I'm trying to code anelementthat shows the comments about a certain
> > > > > item, but when I'm using thepaginatorhelper 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to