Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Upgrading SilverStripe

Ask questions about upgrading SilverStripe to the latest version.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[Solved] The method 'setpagesize' does not exist on 'PaginatedList'


Reply

2 Posts   694 Views

Avatar
TC81

27 March 2013 at 1:04am Community Member, 11 Posts

I'm upgrading a site from 2.4.5 to 3.0.5 and I've managed to resolve most of the issues I have come up against, but this one has got me stumped.

I have a custom module - a "song library" - that is made up of several dataObjects: song, theme, subtheme and publisher. I use a custom searchcontext to provide search facilities on the front end of the site with paginated results. This was working fine in 2.4.5. I've done some minor tweaks (getting changing methods to populate dropdown menu's etc) but otherwise the actual search functions are basically exactly what's here: http://doc.silverstripe.org/framework/en/reference/searchcontext

I can get the search function to return un-paginated results, but when I try and use paginated results I get the following error:

the method 'setpagesize' does not exist on 'PaginatedList'

I'm a bit stuck because my functions are so close to the examples I don't get it. Is it possibly something in the template? One of the only differences is I use: renderWith(array('SongSearch_results', 'Page'); instead of renderWith('SongSearch_results'); but I've tried changing that line and it seems to make no difference.

Avatar
TC81

27 March 2013 at 6:34am Community Member, 11 Posts

I could be wrong but it appears that the code at http://doc.silverstripe.org/framework/en/reference/searchcontext is actually incorrect. In order to use paginated results I've used the following instead:

public function doSearch($data, $form) {
       $context = singleton('MyObject')->getCustomSearchContext();
       $results = $context->getResults($data);
       $results = new PaginatedList($results, $this->request);
      
       return $this->customise(array(
       'Results' => $results
       ))->renderWith(array('MyObject_results', 'Page'));
      }


Just thought I'd share incase anyone else runs into the same problem - it may be the code on that page works and I was making some other mistake, but the above snippet seems to have done the trick for me.