切换Umbraco中的导航元素

时间:2017-12-13 20:27:26

标签: javascript umbraco7

我有一个Umbraco树导航。我想在点击父母时切换孩子(显示/隐藏)。最初只显示根元素。知道我已经显示了所有元素。我的代码如下所示:

<div>
        @foreach (var childPage in sectionPage.Children.Where("Visible"))
        {
             @Umbraco.Field("umbracoNaviHide")
                 <p>

                 <a href="@childPage.Url">@childPage.Name</a>
                            @* if the current page has any children, where the property umbracoNaviHide is not True *@
                            @if (childPage.Children.Where("Visible").Any())
                            {                    
                                @* Call our helper to display the children *@
                                @childPages(childPage.Children)
                            }
                 </p>
             <!--}-->
        }
    </div>

 @helper childPages(dynamic pages) 
    { @* Ensure that we have a collection of pages @ if (pages.Any()) { @ Get the first page in pages and get the level *@ var naviLevel = pages.First().Level;
        @* Add in level for a CSS hook *@
        <div class="level-@(naviLevel)">
            @foreach (var page in pages.Where("Visible"))
            {
                <p>
                    <a href="@page.Url">@page.Name</a>
                    @* if the current page has any children, where the property umbracoNaviHide is not True *@
                    @if (page.Children.Where("Visible").Any())
                    {                        
                        @* Call our helper to display the children *@
                        @childPages(page.Children)
                    }
                </p>
            }
        </div>
    }

0 个答案:

没有答案