Jump to:

23370 Posts in 18156 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree'

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

Page: 1
Go to End
Author Topic: 1343 Views
  • otherjohn
    Avatar
    Community Member
    125 Posts

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

    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;
    }

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree' Link to this post

    ... $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.

  • otherjohn
    Avatar
    Community Member
    125 Posts

    Re: Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree' Link to this post

    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

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: Uncaught Exception: Object->__call(): the method 'subpagestocache' does not exist on 'SiteTree' Link to this post

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

    1343 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.