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

Really weird problem


Reply


3 Posts   276 Views

Avatar
Bagzli

Community Member, 37 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
simon_w

Forum Moderator, 474 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, 37 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.