Thanks, I think your right about the component being the way to go, but the manual doesn't give much information about creating components.
How would I access the Document model from the component, and how would I pass the pagination data to the view from the component? Sorry if these are basic questions. ----- Original Message ---- From: patcoll <[EMAIL PROTECTED]> To: CakePHP <[email protected]> Sent: Wednesday, May 21, 2008 2:28:26 PM Subject: Re: Using pagination with requestAction() Without testing it, this should be true AFAIK: The variable that is returned by the getDocuments() method must be the result of a $this->paginate() call within the controller, and the view in which you're calling renderElement() should have access to the Paginator helper. Once you have that set up you can do stuff like: $documents = $this->requestAction('/documents/getDocuments/limit:5/ page:2'); See where I'm going? If you have that structure you can pass in paginator-like logic to the urls you call thru requestAction. Usual disclaimer: If you see yourself going down the route of using requestAction() a lot, your design decisions should probably be examined more closely. For example, if you see yourself needing to get these "documents" in a lot of views that you're managing, consider putting that custom logic in a Component so you can reuse that logic throughout. Hope this helps. On May 21, 2:00 pm, mustan9 <[EMAIL PROTECTED]> wrote: > Hi, > > I have a controller that provides a list of documents using the > requestAction from a view. > > For example in my view for another controller: > > $documents = $this->requestAction( '/documents/getDocuments' ); > > foreach( $documents as $doc ) > { > echo $this->renderElement( 'description', $doc ); > > } > > Is it possible to use pagination with this approach? I changed my > getDocuments to call $this->paginate('Document'), and my view renders > the list of documents. > > When I tried to add: > > echo $paginator->prev('« Previous ', null, null, array('class' => > 'disabled')); > echo $paginator->next(' Next »', null, null, array('class' => > 'disabled')); > echo $paginator->counter(); > > I get a few undefined variable errors from the paginator helper. What > do I need to do in my getDocuments action to get these variables into > the view? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
