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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

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

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


Go to End


2 Posts   2010 Views

Avatar
TC81

Community Member, 11 Posts

27 March 2013 at 1:04am

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

Community Member, 11 Posts

27 March 2013 at 6:34am

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.