Jump to:

23471 Posts in 18937 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Really weird problem

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: 236 Views
  • Bagzli
    Avatar
    Community Member
    31 Posts

    Really weird problem Link to this post

    Hey guys, I am wondering why does this works:

    <?php
    class ArticleHolder extends Page {
    private static $allowed_children = array('ArticlePage');
    }
    class ArticleHolder_Controller extends Page_Controller {
    public function PaginatedPages() {
    $results = ArticlePage::get()->sort('Date DESC');
    $paginatedItems = new PaginatedList($results, $this->request);
    $paginatedItems->setPageLength(3);
    return $paginatedItems;
    }
    }

    and then this does not

    <?php
    class ArticleHolder extends Page {
    private static $allowed_children = array('ArticlePage');
    }
    class ArticleHolder_Controller extends Page_Controller {
    public function PaginatedPages() {
    $results = Testing();
    $paginatedItems = new PaginatedList($results, $this->request);
    $paginatedItems->setPageLength(3);
    return $paginatedItems;
    }

    public function Testing(){
    return ArticlePage::get()->sort('Date DESC');
    }
    }

    Any thoughts?

  • simon_w
    Avatar
    Forum Moderator
    473 Posts

    Re: Really weird problem Link to this post

    Testing() is a method, so you need to use $this->Testing() to call it.

  • Bagzli
    Avatar
    Community Member
    31 Posts

    Re: Really weird problem Link to this post

    that would explain why

    $this.Testing();

    wasn't working either. Thank you, I will give this a shot tonight.

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