Different template for first item - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Different template for first item

  • I have created a custom module called "Slider". I would like to create an mvc view where the first item shows the picture, title, description, and url (all fields in the custom module), but has a different format for the remaining items.

    Is there a way to do a @foreach (var item in Model.Items) for just the first, and then something else for the rest?

  • You could add a counter for the forEach and put the conditional on if it's a count of 1.   Also, depending on what you're changing maybe handle it with CSS and a :first-child selector.    

    Both are pretty low tech, but likely could work.