<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Page comments</title>
		<link>http://www.ssbits.com/home/</link>
		<atom:link href="http://www.ssbits.com/home/" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_413</link>
			<description>Thanks for this! Led me the way to the light!

By the way: the link to the SilverStripe pagination tutorial/recipe in the article is broken, it currently resides here: http://doc.silverstripe.org/old/private:recipes:pagination</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_413</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_226</link>
			<description>Thanks Marcus!
That's very helpful. Nice tutorial writing too - it will be great if you get the go-ahead to revise it.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_226</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_225</link>
			<description>Yes pretty much.

You have to use Manuels code in every getter where you want to paginate a DataObjectSet that needs to be filtered after the db query.

You could also write a helper function with the stuff that Manuel suggests and use that every time you need to do this.

I'd do a method called paginate() that accepts the relevant DOSet and returns the paginated version. That method would keep track of the GET variables etc so you wouldn't have to clutter the getter with that stuff.

I'll ask Aram if it's ok and if it is, I'll change this tutorial to how I'd actually do it today.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_225</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_224</link>
			<description>Sorry - just to clarify I'm doing things right:

- Manuel's code makes all your code obsolete
- you place it in a PageController (or equivalent)
- you can access different pages through the url with ?start= (is there a cleaner ss way of doing this?)

Am I right?

Cheers &amp; thanks</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_224</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_153</link>
			<description>@Manuel Man I'd actually missed the getRange() method! I could have sworn I searched for an equivalent to array_slice() but couldn't find it but it's  right there.

Manuels way of doing it actually makes more sense, it becomes easier in the template since you'll always be using the same object for all of it and you skip the __call() so it should be faster as well.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_153</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_152</link>
			<description>Hi, my solution for pagination of custom DataObjectSets looks like this:

public function getChildPages() {
    $kids = DataObject::get('ViewableObjectsHolder', &quot;ParentID = '{$this-&gt;ID}'&quot;, 'Sort');
    foreach ($kids as $kid) {
      $kid-&gt;controller = ModelAsController::controller_for($kid);
    }
    return $kids;
  }
  
  public function getChildObjects($items_per_page = 10) {
    $objects = new DataObjectSet();
    $kids = $this-&gt;getChildPages();
    foreach ($kids as $kid) {
      $objects-&gt;merge($kid-&gt;controller-&gt;getObjects('', false));
    }
    if (empty($items_per_page) || $items_per_page &lt; 1) $items_per_page = 10;
    if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] &lt; 1) $_GET['start'] = 0;
    
    $o = $objects-&gt;getRange((int)$_GET['start'], (int)$items_per_page);
    $o-&gt;setPageLimits((int)$_GET['start'], (int)$items_per_page, $objects-&gt;Count());
    return $o;
  }

The important lines are the last ones of the 'getChildObjects' method.

Hope it helps...</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_152</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_139</link>
			<description>@Daniel

That sounds pretty awesome. Would you just cache the results from the query and filtering and live with the cost of slicing a really big array or would you try to find a way to cache each page separately? Also how big would you let the result set get before you'd seriously start considering going the cache route?

Just caching the results after the filtering seems to be pretty trivial with cacheToFile() if I'm reading the code correctly. Thank you for the awesome tip, I will be trying it out soon.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_139</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_138</link>
			<description>@Marcus

Yes, there is a very simple way to cache an output of a function. I use two methods, one is this in the init() of a controller:

$this-&gt;FuncName = $this-&gt;cacheToFile('FuncName',$lifetime,$ID,(array)$arguments);

The other is this:
function() FuncName() {
if (!isset($this-&gt;FuncName) {
$this-&gt;FuncName = some complicated fetching etc;
}
return $this-&gt;FuncName;

I might write a lil tut on caching in the contoller</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_138</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_137</link>
			<description>You can take a look at Aram's custom search mod hidden in the forums.

http://www.silverstripe.org/all-other-modules/show/6641?start=24#post290089

Specially the part from r303 at $records = DB::query($fullQuery);

After the query the result will be pushed in a DO set as well, but its much smaller, since its not getting the full DataObjects.

That still does not prevent you checking canView on each DO though...</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_137</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_136</link>
			<description>Hi Dan,

Unfortunately no, I don't think there is an easy way around this unless you cache the initial query and filtering in some way. The big issue is that you're filtering after the results have been fetched, presumably because you can't filter the result directly in the database query.

If you can filter in the database query that's of course alot better but there needs to be some kind of solution for when you can't too. Is there a simple way to cache a DataObjectSet in SilverStripe? If there is then let me know and we can add that to the tutorial. It would be really nice to cache the filtered result after the first query and then just use that on subsequent calls.

Has anyone tried caching DataObjectSets and knows how to go about this?</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/tutorials/2010/paginating-a-filtered-dataobjectset/#PageComment_136</guid>
		</item>
		

	</channel>
</rss>