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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Really weird problem


Go to End


3 Posts   630 Views

Avatar
Bagzli

Community Member, 71 Posts

6 February 2014 at 12:38pm

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?

Avatar
(deleted)

Community Member, 473 Posts

6 February 2014 at 1:54pm

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

Avatar
Bagzli

Community Member, 71 Posts

7 February 2014 at 2:36am

Edited: 07/02/2014 2:36am

that would explain why

$this.Testing();
wasn't working either. Thank you, I will give this a shot tonight.