Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    Jan 11, 2016 @ 17:27
    Steve
    0

    Previous and Next Button Navigation

    I have some previous and next buttons, but when I try to add some conditionals to them the script does't load anymore. I also would like to have it check for previous and next siblings, in case one of them is not visible (umbracoNaviHide).

    Here is my inline macro from the template:

    <umbraco:Macro runat="server" language="cshtml">
        <div class="prevNextWrap">
            @{
            if (@Model.Previous().Where("Visible && NodeTypeAlias == \"TwoColumnAdmissionsLeftNav\" || NodeTypeAlias == \"OneColumnAdmissions\"")){
                    <a class="prevNext" href="@Model.Previous().Url">Previous</a>
                }
             if (@Model.Next().Where("Visible && NodeTypeAlias == \"TwoColumnAdmissionsLeftNav\" || NodeTypeAlias == \"OneColumnAdmissions\"")){
                    <a class="prevNext" href="@Model.Next().Url">Next</a>
                }
        }
        </div>
    </umbraco:Macro>    
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 11, 2016 @ 18:03
    Dennis Aaen
    0

    Hi Steve,

    To check there is a next and previous node you could use

    @Model.Next() != null 
    @Model.Previous() != null
    

    Could you try the code snippet below and see if it solve your issue.

    <umbraco:Macro runat="server" language="cshtml">
        <div class="prevNextWrap">
            @{
            if (@Model.Previous().Where("Visible && NodeTypeAlias == \"TwoColumnAdmissionsLeftNav\" || NodeTypeAlias == \"OneColumnAdmissions\"")){
                    @if(Model.Previous() != null){
                        <a class="prevNext" href="@Model.Previous().Url">Previous</a>
                    }
                }
             if (@Model.Next().Where("Visible && NodeTypeAlias == \"TwoColumnAdmissionsLeftNav\" || NodeTypeAlias == \"OneColumnAdmissions\"")){
                    @if(Model.Next() != null){
                        <<a class="prevNext" href="@Model.Next().Url">Next</a>
                    }
    
    
                }
        }
        </div>
    </umbraco:Macro>    
    

    Hope this helps,

    /Dennis

  • Steve 472 posts 1216 karma points
    Jan 11, 2016 @ 19:37
    Steve
    0

    Sorry Dennis, but this doesn't load. I'll keep trying different syntax.

    EDIT: It seems that the error happens when the navigation gets to the first or ending node in the group.

  • 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