Copied to clipboard

Flag this post as spam?

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


  • Hubert Thalmann 57 posts 263 karma points
    Aug 30, 2016 @ 09:40
    Hubert Thalmann
    0

    Umbraco Childrens Children

    Hello Our.Community

    I have a Problem. I want to write a Macro that displays me first the Children and then the Childrens Children.

    Here is my Structure. enter image description here

    and i want now to Display something like:

    Präsidenten

    -Friedli Ludwig

    -Emmenegger Josef

    Vizepräsidenten

    -Wigger Josef

    -Emmenegger Walter

    is that possible? i have the following macro at the moment

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @{ var selection = CurrentPage.Children.Where("Visible"); }
    
    
        @if (selection.Any())
        {
            foreach (var item in selection)
            {
                <div class="row">
                <div class="col-sm-1 col-xs-0">
                </div>
                <div class="col-sm-5 col-xs-12">
                <p class="text">@item.titel</p><br />
                </div>
                <div class="col-sm-5 col-xs-12 text">
                </div>
                </div>      
    
                { var selection2 = (@item.page).Children.Where("Visible"); }
                foreach (var item2 in selection2)
                {
                    <p>@item2.MitgliederName</p>
                }
    
    }
    }
    

    but i get the following error:

    Compiler Error Message: CS0103: Der Name 'selection2' ist im aktuellen Kontext nicht vorhanden.

    english: selection2 does not exist.

    Source Error:

    Line 20:
    Line 21: { var selection2 = (@item.page).Children.Where("Visible"); }

    Line 22: foreach (var item2 in selection2)

    Line 23: {

    Line 24:

    what am i doing wrong?

  • Hubert Thalmann 57 posts 263 karma points
    Aug 30, 2016 @ 09:47
    Hubert Thalmann
    100

    i solved the problem.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    
    @{ var selection = CurrentPage.Children.Where("Visible"); }
    
    
    @if (selection.Any())
    {
            foreach (var item in selection)
            {
                <div class="row">
                <div class="col-sm-1 col-xs-0">
                </div>
                <div class="col-sm-5 col-xs-12">
                <p class="text">@item.titel</p><br />
                </div>
                <div class="col-sm-5 col-xs-12 text">
                </div>
                </div>      
    
                var selection2 = (@item).Children.Where("Visible");
                foreach (var item2 in selection2)
                {
                    <p>@item2.MitgliederName</p>
                }
    
    }
    }
    
  • 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