0

I am completely new to Expression Engine and I am trying to reverse engineer a site that someone else built. From what I understand, there is a plugin called "Structure" which controls the main navigation of the site.

{exp:ce_cache:escape}
    {exp:ce_cache:it:nested id="topnav" global="no" seconds="3600"}
        {exp:structure:nav start_from="/" show_depth="2" max_depth="2" add_unique_ids="yes" css_class="topnav" css_id="none" current_class="current" include="3|4|5|17|18" exclude="10"}
    {/exp:ce_cache:it:nested}
{/exp:ce_cache:escape}

There is a navigation item which contains too many sub-items (which results in a really long drop-down), so my task is to hide the sub-items while keeping the page that they link to. I went to the "Structure" section of admin and only found the ability to delete pages.

How can I hide the drop-down for this particular nav item?

0

If I am understanding you, you would like to hide all the subitems and keep the main navigation unchanged? This can be done by changing show_depth="2" to show_depth="0". That way all you will see is the main navigation and there will no longer be a dropdown for the subitems.

{exp:ce_cache:escape}
    {exp:ce_cache:it:nested id="topnav" global="no" seconds="3600"}
        {exp:structure:nav start_from="/" show_depth="0" max_depth="2" add_unique_ids="yes" css_class="topnav" css_id="none" current_class="current" include="3|4|5|17|18" exclude="10|#|#|#|#"}
    {/exp:ce_cache:it:nested}
{/exp:ce_cache:escape}
5
  • If I understand correctly, this would affect all the nav items. I only want to hide one particular drop down (ID #17) and keep the rest.
    – Andrew
    Oct 29 '14 at 5:19
  • In order to do that you need to remove it from include="3|4|5|17|18" and move it to exclude="10|17". Is #17 the parent nav for subpages? If so just go into the CP and get the ID's for the subpages and just add those to the exclude.
    – jneustrom
    Oct 29 '14 at 5:36
  • But wouldn't that remove 17 from the nav entirely? I just want to hide its children.
    – Andrew
    Oct 29 '14 at 5:38
  • Place the subpages of #17 exclude tag, once you do that the dropdown will no longer appear and you will be able to navigate without issue.
    – jneustrom
    Oct 29 '14 at 5:40
  • I don't think this will work for me. If ever an admin adds a new page, the template will have to be updated too. I need a dynamic solution, not something hard coded.
    – Andrew
    Oct 29 '14 at 5:44
0

I learned that the Structure plugin does not provide a way of controlling the depth of an individual navigation item, so I came up with a hack to address this issue. By using a little bit of Javascript, I am removing the subnav/dropdown <ul>:

<script type="text/javascript">
  var ul = document.getElementById('my-nav-item').getElementsByTagName('ul')[0];
  ul.parentNode.removeChild(ul);
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.