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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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