diff --git a/code/BlogTree.php b/code/BlogTree.php index 32758f4..a8ace83 100644 --- a/code/BlogTree.php +++ b/code/BlogTree.php @@ -61,12 +61,12 @@ class BlogTree extends Page { if($top) return $top; // Try to find any BlogTree that is not inside another BlogTree - foreach(DataObject::get('BlogTree') as $tree) { + if($blogTrees=DataObject::get('BlogTree')) foreach($blogTrees as $tree) { if(!($tree->getParent() instanceof BlogTree)) return $tree; } // This shouldn't be possible, but assuming the above fails, just return anything you can get - return DataObject::get_one('BlogTree'); + return $blogTrees; } /* ----------- ACCESSOR OVERRIDES -------------- */ @@ -349,4 +349,4 @@ class BlogTree_Controller extends Page_Controller { return date("Y", mktime(0, 0, 0, date('m'), 1, $date)); } } -} \ No newline at end of file +}