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

Extending DataObjectSet by FirstPageLink, LastPageLink


Go to End


1200 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);
}
}