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

Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree'


Reply


4 Posts   1425 Views

Avatar
otherjohn

Community Member, 125 Posts

8 August 2010 at 8:12am

This is odd, anyone have an idea whats going on.
When I do a buildcache it gives me this error
Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree'
but in my page.php file I have
function allPagesToCache() {
// Get each page type to define its sub-urls
$urls = array();

// memory intensive depending on number of pages
$pages = DataObject::get("SiteTree", "ClassName != 'UserDefinedForm'");

foreach($pages as $page) {
$urls = array_merge($urls, (array)$page->subPagesToCache());
}

// add any custom URLs which are not SiteTree instances
$urls[] = "sitemap.xml";

return $urls;
}

/**
* Get a list of URLs to cache related to this page
*/
function subPagesToCache() {
$urls = array();

// add current page
$urls[] = $this->Link();

// cache the RSS feed if comments are enabled
if ($this->ProvideComments) {
$urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID;
}

return $urls;
}

function pagesAffectedByChanges() {
$urls = $this->subPagesToCache();
if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
return $urls;
}

Avatar
Willr

Forum Moderator, 5513 Posts

8 August 2010 at 11:18am

... $pages = DataObject::get("SiteTree", "ClassName != 'UserDefinedForm'");

Will probably need to make it get the 'Page' objects not the 'SiteTree' objects so it calls that function on Page.php and not SiteTree.php.

Avatar
otherjohn

Community Member, 125 Posts

8 August 2010 at 12:49pm

I will give that a try. Whats odd, is that I have another site that I used the same code on and it works fine!
John

Avatar
ttyl

Community Member, 114 Posts

21 September 2010 at 6:55am

Edited: 21/09/2010 7:07am

I also got this error (using 2.4.1). switching to 'page' from 'sitetree' works.