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

Next and Previous page links


Go to End


2 Posts   1526 Views

Avatar
mattupstate

Community Member, 12 Posts

5 August 2011 at 3:57am

Say I have a "ProjectsHolder" page type, and its children are only of type "ProjectPage". From within "ProjectPage" is there an easy way to get the next and previous pages from the children of "ProjectsHolder" ?

Avatar
MarcusDalgren

Community Member, 288 Posts

5 August 2011 at 5:31am

If you know what you're ordering them by then yes. Not sure exactly how you want to do it but if you're using the Sort column from SiteTree then you can write your own function in ProjectPage that fetches the next page in the sequence.

For example

function NextProject() {
	return DataObject::get_one("ProjectPage", "Sort = ".($this->Sort+1));
}

Now if you have several project holders you need to add the ParentId as well but that should be the gist of it. In the template for a ProjectPage you can now write NextProject.Link to get the page link.