Copied to clipboard

Flag this post as spam?

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


  • DonZalmrol 220 posts 833 karma points
    Jan 07, 2017 @ 16:58
    DonZalmrol
    0

    Umbraco & bootstrap accordion that unfolds when you are on the active page.

    Hi all,

    Might be a bit of a different question for Umbraco, but I'm creating an accordion side navigation for my company's site.

    The accordion works with Umbraco, but I cannot get it to stay open when you click on a link.

    So when you click on Our business it closes again, but I wish that it open on the current page.

    enter image description here

    Like so:

    enter image description here

    Thank you in advance! :)

  • DonZalmrol 220 posts 833 karma points
    Jan 07, 2017 @ 17:23
    DonZalmrol
    0

    Getting there step by step.

    Was able to set it to page name, but now I need to do the same for the sub items of the pages.

    enter image description here

  • DonZalmrol 220 posts 833 karma points
    Jan 07, 2017 @ 17:55
    DonZalmrol
    100

    I think I have it, but need to find a way to make it cleaner and that it will go down all the child items, children of children, etc... (in other words when you traverse really deep in the site).

    @{
         var setCollapse = "out";
    }
    
    @if(@childPage.Name == currentPageName)
                    {
                        setCollapse = "in";
    
                        @*<p>1 - childPage == currentpage : @setCollapse</p>*@
                    }
    
                    else
                    {
                        setCollapse = "out";
    
                        @*<p>2 - childPage != currentpage : @setCollapse</p>*@
                    }
    
                    @foreach (var page in childPage.Children.Where("Visible"))
                    {
                        if(@page.Name == currentPageName)
                        {
                            setCollapse = "in"; 
    
                            @*<p>3 - page == currentpage : @setCollapse</p>*@
                        }
    
                        foreach (var pages in page.Children.Where("Visible"))
                        {
                            if(@pages.Name == currentPageName)
                            {
                                setCollapse = "in"; 
                            }
                        }   
    
                    }
    
                        <div id="@counter" class="panel-collapse collapse @setCollapse"> ... </div>
    
  • DonZalmrol 220 posts 833 karma points
    Jan 08, 2017 @ 07:34
    DonZalmrol
    0

    Is there a way in Umbraco that I can get the total amount of children (or depth)

    e.g.:

    • Parent (level 0)
      • level 1 item 0
      • level 1 item x
        • level 2 item 0
        • level 2 item x
          • level 3 item 0
          • level 3 item x
            • level x item x
Please Sign in or register to post replies

Write your reply to:

Draft