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

Extending DataObjectSet by FirstPageLink, LastPageLink


Reply


972 Views

Avatar
rainerh

Community Member, 23 Posts

20 November 2009 at 11:42pm

Hello,

is it possible to extend DataObjectSet by two functions that returns the link for the first respectively the last page? I tried to decorate it by an extension object. Unfortunately the extension object cannot access the $pageSize or $paginationGetVar fields (because they are protected????).
It should be very simpe though. Just add:

   
/**
* Returns the URL of the first page.
* @return string
*/
public function FirstLink() {
if($this->pageStart > 1) {
return HTTP::setGetVar($this->paginationGetVar, 0);
}
}

/**
* Returns the URL of the last page.
* @return string
*/
public function LastLink() {
if($this->pageStart + $this->pageLength < $this->totalSize) {
return HTTP::setGetVar($this->paginationGetVar, ($this->TotalPages() - 1) * $this->pageLength);
}
}