Wow, talk about embarrassing, it seemed like it was going to be much
more complicated than this.
Accomplished my goal for the most part... see below for an explanation
of what I've done, but I still have one small issue. It doesn't seem
to be effecting the rendering or parsing of any of the code (no errors
anyway) but when the page is loaded I see two requests for /schools/
view/%s which result in 400 bad request. Sorting the lists or
updating the container results in two requests the good one and a %s.
Any ideas where that's coming from or how I might go about tracking it
down? As far as I'm aware there is nothing in my code that would
result in an URL ending with %s....
Now for the other part:
This was really very simple... I'm not sure if there was a more
efficient way to get it all done in one go but all it took to do what
I wanted above was after running my find for the school and checking
that data was returned I just needed to setup some options on the
paginater, paginate the results, and lastly (not shown here) cutting
out the reports returned by the findBySlug magic function using
contain.
function view($id = null) {
$school = $this->School->findBySlug($id);
if (!empty($school)) {
$this->paginate = array(
'Report' => array(
'conditions' =>
array('Report.school_id' => $school['School']
['id']),
),
);
$this->set('reports', $this->paginate('Report'));
$this->set('school', $school);
}
else {
$this->Session->setFlash(__('No matching school was
found.',
true));
$this->redirect(array('action' => 'index'));
}
}
On Oct 12, 10:49 am, Anthony <[email protected]> wrote:
> Is is possible to paginate based on data returned from a previous
> query?
>
> Example:
>
> I'm displaying the detail for a school. Each school has many reports
> and I would like to paginate just the reports that were returned from
> the query used to look up the school.
>
> My first instinct was to just do something like this: $this-
>
> >paginate($school['Report'])
>
> However this didn't work; I'm guessing because paginate calls find
> itself.
>
> Does this mean I need to use contain to not return the reports the
> first time then make a second query using paginate for the schools
> reports?
>
> Is there a way to do this without making that second query?
>
> Lastly, I followed the ajax (jQuery) pagination examples to make the
> full list of schools and reports paginated with ajax. How can I reuse
> these elements to make the reports section on the view ajax
> paginatable. (I'm pretty sure thats a valid technical term...)
>
> Thanks in advanced for any assistance and insight.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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