Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Only one level being returned for Sitetree


5 Posts   373 Views


9 December 2013 at 11:58pm Community Member, 5 Posts


When I used the code below I don't get the subpages (second and third level of site) in the returned object. For this reason I can't use staticpublisher.

$pages = SiteTree::get()->filter('ParentID', 54);

Running SS 3.1.2 upgraded from 2.4.

Any ideas!




11 December 2013 at 8:32pm Forum Moderator, 5511 Posts

In your example $pages will only be the pages for the a single level. If you want to get the children of those

$pages = SiteTree::get()->filter('ParentID', 54);

foreach($pages as $page) {
$page->Children(); //

Of course you may want to make that recursive so children of children are included.


11 December 2013 at 10:38pm Community Member, 5 Posts

Thanks Willr,

Is there a method that returns every page? Staticpublisher example seem to point to SiteTree::get(); but on my site (c. 2500 pages) when I run it it maxs out CPU for a while and doesn't generate any cached versions of pages. But if I isolate a single branch of the site it runs fine using SiteTree::get()->filter('ParentID', 54); for example. Any tips?



11 December 2013 at 10:46pm Forum Moderator, 5511 Posts

Try staticpublisherqueue ( which will generate pages through an event system and perhaps better for larger sites (and going to be more scalable than the default static publisher).

Do you know what part is causing the delay - the fetch of pages or the actual processing of each page? If it's a fetch, then no nice way apart from querying for the page links in batches. The processing of each page can be batched down a bit so rather than calling RebuildStaticCacheTask and rebuilding all pages at once you can do something like

sake dev/buildcache "start=0&count=300"
sake dev/buildcache "start=300&count=300"


11 December 2013 at 11:11pm Community Member, 5 Posts

Thanks great, thanks a mill for the advice, much appreciated!
(Funny thing is that when the same site was on version 2.3 the staticpublishing worked fine, must be something to do with switch to ORM.)