One of the biggest inconveniencies in the current Silverstripe versions imho, is that there is no way to limit the amount of subpages that the cms displays in its hierarchical tree.
Now in most cases for simple websites, this isn't a problem at all. The problem arises when you're having a blog or a news site that can run into hundreds of subpages of the same parent. It may cause the admin to load very slow, and once loaded, you'll have to scroll down as they're displayed in one long list. Imagine this with like 3000 pages. Right, a problem. This problem has been discussed already in the Silverstripe forums, and some conceptual solutions have been talked about.
Thing is, the best solution would require a lot of code to be rewritten and a very solid understanding of the internals of Silverstripe. As working out the suggested idea is a bit too much work and in my opinion better left to the core developers, I created a possible dirty, but easy solution for this.
With my solution, you'll get an extra field in the behaviour tab, which requires you to set a number. This number defaults to 0, which means: just do nothing and keep it how it is. Once you set a number, you'll have to refresh the page, and the cms will then display for that page only the amount of subpages you set in the parent. So, when set to 20, it will only show the last 20 subpages you created in the cms. Note that this will make you lose the drag 'n' drop ordering you may have set for these subpages. It will sort on 'Created'. (Although you could probably easily add another textfield to make the sort filter adjustable as well.) You can still use the cms search functionality, which will display all results, not using the limit.
The first change you'll have to make is in sapphire/core/model/SiteTree.php.
Add the next line to the static $db array (this will be around line 95 somewhere):
"NumberCMSChildren" => "Int(0)"
Then scroll down in SiteTree.php until you find the code that says:
new TextField(
"HomepageForDomain",
_t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage')
),
Add this beneath it:
new NumericField(
"NumberCMSChildren",
"Total displayed subpages in CMS (must be numeric, defaults to 0 == all, page refresh required after changing this)",
$this->NumberCMSChildren
)
Make sure you don't mix up any braces or comma's, or you'll get an error.
Then open up sapphire/core/model/Hierarchy.php, scroll down to around line 493 where you find the method stageChildren(), like:
public function stageChildren($showAll = false) {
...
} Then, replace this complete function with:
public function stageChildren($showAll = false) {
$extraFilter = $showAll ? '' : " AND ShowInMenus = 1";
$baseClass = ClassInfo::baseDataClass($this->owner->class);
# defaults
$limit = "";
$sort = "";
# check if the request comes from the cms-admin section, allow for content and getsubtree only
$cms = preg_match("/admin(\/)?$/", $_SERVER['REQUEST_URI']) || preg_match("/admin\/getsubtree/", $_SERVER['REQUEST_URI']);
# get limit
$limit = $this->owner->NumberCMSChildren;
# if limit is 0, default to all, or if limit ok, but cms filter false, default to all
if(!$limit || (!$cms && $limit)) $limit = "";
# if all good, make sort so it takes the last ones
if($cms && $limit) $sort = "Created DESC";
# get set
$set = DataObject::get($baseClass, "`{$baseClass}`.`ParentID` = " . (int)$this->owner->ID . " AND `{$baseClass}`.ID != " . (int)$this->owner->ID . $extraFilter, $sort, "", $limit);
# if set, cms and limit, we need to resort to have the last one on bottom
if($set && $cms && $limit) $set->sort("Created ASC");
return $set;
}This hack works because it detects where the request comes from, but then again, this is what makes it a bit a dirty hack too. It will only work if you didn't change the default admin url. This solutions seems to work perfect for me, but only use it after you tested it yourself, I can not be hold responsible if it turns out to break something. So far I haven't encountered any problems, but never say never.
It's a short hack, and hopefully it will be useful. Comments, improvements (I'm sure there are), suggestions... welcome.