From 1163231161aa3c1558a0b3864a2512fb130776d5 Mon Sep 17 00:00:00 2001 From: micmania1 Date: Fri, 23 Aug 2013 16:22:13 +0100 Subject: [PATCH] Add lazy load fix --- extensions/BlogPostFilter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extensions/BlogPostFilter.php b/extensions/BlogPostFilter.php index 1941caa..a548980 100755 --- a/extensions/BlogPostFilter.php +++ b/extensions/BlogPostFilter.php @@ -17,4 +17,16 @@ class BlogPostFilter extends DataExtension { } + /** + * This is a fix so that when we try to fetch subclasses of BlogPost, + * lazy loading includes the BlogPost table in its query. Leaving this table out + * means the default sort order column PublishDate causes an error. + **/ + public function augmentLoadLazyFields(SQLQuery &$query, &$dataQuery, $parent) { + + // Ensures that we're joining the BlogPost table which holds required db fields. + $dataQuery->innerJoin("BlogPost", "`SiteTree`.`ID` = `BlogPost`.`ID`"); + + } + } \ No newline at end of file