Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    May 27, 2013 @ 21:12
    René Andersen
    0

    Only show the first found child data

    Hello everybody

    How do I get this script only showing the first found child data? Is it wrong to use foreach?

    @foreach (var page in @Model.Children.Where("Visible"))
    {
    <div class="tab-pane fade in active" id="@page.id">
    <div class="span8 offset2"><h1 class="post_intro center">@page.header</h1>
    <div class="pad30"></div>
    <div class="post">
    <img src="@page.image" alt="" >
    <div class="pad30"></div>
    <p>@page.description</p>
    <h4 class="grey2"><i class="icon-quote-left icon-3x pull-left colour marg-left5"></i>@page.descriptionQuote</h4>
    <div class="pad25"></div>
    </div>
    </div>
    </div>
    }

    Thanks in advance!

    //René

  • Fuji Kusaka 2203 posts 4220 karma points
    May 27, 2013 @ 21:21
    Fuji Kusaka
    100

    Hi Rene,

    Instead of making of a foreach you could just make a check to see  if Model has Child node and if so display first child only.

    @if(Model.Children.Where("Visible").Count() > 0){
             @Model.Children.First().Name
    }

     

    Hope this helps

    //fuji

  • René Andersen 238 posts 684 karma points
    May 27, 2013 @ 21:45
    René Andersen
    0

    Hi Fuji,

    Thank you for the quick reply on all my posts today.

    This solved my problem. :-)

    I will get back to you when I have solved the problem on the other post:

    http://our.umbraco.org/forum/developers/razor/41296-Active-tab-problem

    //René


Please Sign in or register to post replies

Write your reply to:

Draft