我想获取 Silverstripe 网站的所有 SiteTree 页面,然后按深度降序对它们进行排序。我所说的深度是指他们拥有的父母数量。
谷歌站点地图模块已经在某种程度上做到了这一点。除了它不超过 10 的深度并且不计算从搜索中隐藏的页面:https ://github.com/silverstripe-labs/silverstripe-googlesitemaps
查看 Google Sitemaps Module 模块,计算页面的父级数量似乎很容易:(/code/GoogleSitemapDecorator.php - 第 78 行)
$parentStack = $this->owner->parentStack();
$numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
但是使用此计算对 SiteTree 进行排序的最佳方法是什么?
我希望有一种比获取所有 SiteTree、附加深度然后再使用更简单的方法。