Navigation Menu Top Level Folder

Aaron Smith's Avatar

Aaron Smith

16 Aug, 2016 05:22 PM

I inherited a Cascade site that uses a dynamically generated navigation menu with drop-downs. On the menu, the top level links are just used to activate the drop-down and the link is overridden. Unfortunately, because of how the dynamic nav menu is structured, if there are links in the drop-down that also contain child folders, the link is again overridden because the same code is generating link.

Is there a way to identify the top level of the folder structure, so I can use a conditional statement to only add the data-toggle at that level?

Here's the site:

And here's the code:
#set ($isFolder = ($asset.identifer.type == $"com.hannonhill.cascade.model.dom.identifier.EntityTypes").TYPE_FOLDER))

#if ($isFolder && $childCount == 1)
            <a href="$">$displayName</a>
        #elseif ($isFolder && $childCount > 1)
            <a href="$" class="dropdown-toggle" data-toggle="dropdown">$displayName<span class="caret"></span></a>
            <a href="$">$displayName</a>

  1. 1 Posted by Ryan Griffith on 16 Aug, 2016 07:09 PM

    Ryan Griffith's Avatar

    Hi Aaron,

    To confirm, do you just need to check if the folder is at the root level? If so, you could just check it's path to see if it contains a / or not. Top level folders would not contain a slash, while nested folders would. A couple of ways you could check:

    ## no '/' is present at all:
    $asset.path.indexOf("/") == -1
    ## size of "folder structure" is 1
    $asset.path.split("/").size() == 1

    Please let me know if you have any questions.


  2. 2 Posted by Aaron Smith on 16 Aug, 2016 08:27 PM

    Aaron Smith's Avatar

    That did the trick! Thanks for your help!

  3. 3 Posted by Ryan Griffith on 17 Aug, 2016 02:26 PM

    Ryan Griffith's Avatar

    Not a problem at all, Aaron. I am glad to hear the proposed snippets worked out.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  4. Ryan Griffith closed this discussion on 17 Aug, 2016 02:26 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM