Copied to clipboard

Flag this post as spam?

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


  • Bas Schouten 135 posts 233 karma points
    Jun 17, 2016 @ 08:51
    Bas Schouten
    0

    Navigation between nodes of documenttype

    Hi All,

    I'm trying to build a navigation between nodes from the same documenttype.

    @if (@CurrentPage.Where("NodeTypeAlias == \"Nieuwsitem\"").Previous() != null) {
         <a href="@CurrentPage.Where("NodeTypeAlias == \"Nieuwsitem\"").Previous().Url">Previous</a>
    }
    

    This is not working.

    bool' does not contain a definition for 'Previous

    What am i doing wrong?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jun 17, 2016 @ 11:38
    Dan Diplo
    100

    Here's how I do previous and next links for a given docType alias, which might help:

    string alias = "Nieuwsitem"; // your docType alias
    
    var previousPage = Model.Content.Previous();
    var nextPage = Model.Content.Next();
    
    if ((previousPage != null && previousPage.DocumentTypeAlias == alias) || (nextPage != null && nextPage.DocumentTypeAlias == alias))
    {
        <ul class="pager">
            @if (previousPage != null && previousPage.DocumentTypeAlias == alias)
            {
                <li class="previous">
                    <a href="@previousPage.Url#main" class="prev" rel="prev" title="@previousPage.Name">
                    <i class="fa fa-angle-left"></i> Previous</a>
                </li>
            }
            @if (nextPage != null && nextPage.DocumentTypeAlias == alias)
            {
                <li class="next">
                    <a href="@nextPage.Url#main" class="next" rel="next" title="@nextPage.Name">
                    Next <i class="fa fa-angle-right"></i></a>
                </li>
            }
        </ul>
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies