Jump to:

23471 Posts in 18937 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Next and Previous page links

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

Page: 1
Go to End
Author Topic: 792 Views
  • mattupstate
    Avatar
    Community Member
    12 Posts

    Next and Previous page links Link to this post

    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" ?

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Next and Previous page links Link to this post

    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.

    792 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.