Developer forum

Forum » CMS - Standard features » Headerstart and Razor

Headerstart and Razor

Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi,

A totally newbie question, I know :)
Are there any equal to Headerstart in loops in Razor?

Best regards
Kurt


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kurt.

Nope - they only exist in the html templates because there are no other way to see if there are items in the loop.

In Razor you can use C# syntax - including LINQ. So you can do something like this (not real code, but close :-)):

myLoop = GetLoop("Whatever")
if(myLoop.any()){
    <ul>
    foreach(loopitem in myLoop){
        <li>loopitem.GetValue()</li>
    }
    </ul>
}
Votes for this answer: 1
 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Thanks, Nicolai.

I had a hunch :)

 

You must be logged in to post in the forum