Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Jun 26, 2014 @ 15:50
    Claushingebjerg
    0

    Checking if node is first node in archetype

    Im using Archetype to make a slider, and need to identify the first "node"

    @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("slider"))
    {
       @if(fieldset.IsFirst()) {
          <p>True</p>
       } else {
          <p>False</p>
       }
    }

    What am i doing wrong here?

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 26, 2014 @ 15:59
    Jeavon Leopold
    100

    Hi Claus,

    IsFirst is a method only on IPublishedContent, it doesn't exist on with ArchetypeModel, you will need to do something like this:

     @{
         var slider = Model.Content.GetPropertyValue<ArchetypeModel>("slider");
    
         foreach (var fieldset in slider)
        {
            if (fieldset.Equals(slider.First()))
            {
                <p>True</p>
            }
            else
            {
                <p>False</p>
            }
        }
    }    
    

    Jeavon

  • Claushingebjerg 939 posts 2574 karma points
    Jun 27, 2014 @ 09:16
    Claushingebjerg
    0

    Worked, thanks

  • 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