Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Kibsgård 62 posts 73 karma points
    Aug 06, 2012 @ 11:30
    Simon Kibsgård
    0

    Get following Page in some chapter

    I am looking for a way to browse pages in a book made from umbraco nodes.

    It has this structure

    Book 1
    --Chapter 1
    ----Page 1
    ----Page 2
    ----Page ...
    --Chapter 2
    ----Page 1
    ----Page ...
    Book 2
    --Chapter 1
    ----Page 1
    ----Page...

    On each page I would like to get the next page and link to it, even if it's in the next chapter - but not if it's in the next book.

    I have managed to make it work in XSLT with below selector (though it still goes in to next book, but I will deal with that later). But can anyone tell me how to get the next Page with Razor?

    <xsl:param name="nextPage" select="$currentPage/following::Page[@isDoc][1]"/>

    @Model.Next("Page") seems to only work within a chapter.

    Thanks, Simon K

  • Simon Kibsgård 62 posts 73 karma points
    Aug 13, 2012 @ 22:04
    Simon Kibsgård
    0

    bump. Any Razor guns out there?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 13, 2012 @ 22:13
    Bo Damgaard Mortensen
    0

    Hi Simon,

    You could simply parse your way through the tree with .Up(1); Next(1); etc etc. You could also just get all of the pages in a collection by:

    var pages = Model.AncestorOrSelf("Book").Descendants().Where("NodeTypeAlias = 'Page'");

    .. and then find the next page in the collection :-)

    Or, you could go for an XPath expression: 

    var nextPage = Model.XPath("YourXPathHere");

    The above code-snippets are untested, though.

    Let me know how it turns out :-)

    - Bo

Please Sign in or register to post replies

Write your reply to:

Draft