Sub menu showing children and parent


(Nic Hubbard) #1

I have built design parse files 1000 times, but it is late and I am not thinking how to figure this one out.

 

In my subnav menu, I would like to show the parent top level page as the first item, and then show all the children. So far, I am only getting the children to show, using:

 

<MySource_AREA id_name="subnav_menu" design_area="menu_normal">

    <MySource_SET name=“level” value=“1”/>
    <MySource_SET name=“show_subs” value=“always”/>
    <MySource_SET name=“settings.class.normal” value="" />
    <MySource_SET name=“settings.class.hierarchy” value="" />
    <MySource_SET name=“settings.class.current” value=“active” />

    <div class=“navigation-parent”>
        <ul>
        <MySource_ASSET>
            <li class="<MySource_PRINT var=‘settings.class’ />">
                <MySource_PRINT var=“asset_short_name_linked” />
                
                <MySource_SUB design_area=“menu_normal”>
                <MySource_SET name=“show_subs” value=“on_current”/>
                <MySource_SET name=“settings.class.normal” value="" />
                <MySource_SET name=“settings.class.hierarchy” value="" />
                <MySource_SET name=“settings.class.current” value=“active” />
                
                <ul class=“sub-menu”>
                <MySource_ASSET>
                    <li class="<MySource_PRINT var=‘settings.class’ />">
                        <MySource_PRINT var=“asset_short_name_linked” />
                        
                        <MySource_SUB design_area=“menu_normal”>
                        <MySource_SET name=“settings.class.normal” value="" />
                        <MySource_SET name=“settings.class.hierarchy” value="" />
                        <MySource_SET name=“settings.class.current” value=“active” />
                        
                        <ul class=“sub-menu”>
                        <MySource_ASSET>
                            <li class="<MySource_PRINT var=‘settings.class’ />">
                                <MySource_PRINT var=“asset_short_name_linked” />
                            </li>
                        </MySource_ASSET>
                        </ul>
                        </MySource_SUB>
                    </li>
                    </MySource_ASSET>
                </ul>
                </MySource_SUB>
            </li>
        </MySource_ASSET>
        </ul>
    </div>
    
</MySource_AREA> 

So, say this is my hierarchy:

 

  • Top Page 1
  • -- Sub Page 1
  • -- Sub Page 2
  • Top Page 2
  • -- Sub Page 1
  • -- Sub Page 2
  • Top Page 3

 

So, when accessing one of the Sub Pages, I would like it to show Top Page as well as Sub Pages. Does anyone have ideas on how I can show the parent page as the first item?

 


(Talk) #2

Hi Nic, this is what I use for menus with subs:

 

<MySource_AREA id_name="menu_dropdown" design_area="menu_normal">
<MySource_SET name="show_subs" value="always" />
<MySource_SET name="settings.class.normal" value="" />
<MySource_SET name="settings.class.current" value="current" />
<MySource_SET name="settings.class.hierarchy" value="parent" />
<nav id="nav1" class="listNav"><ul> <!-- NAV1 -->
<MySource_ASSET><li id="nav_<MySource_PRINT var="asset_assetid" />" class="navLink"><a href="<MySource_PRINT var="asset_link" />" class="<MySource_PRINT var="settings.class" />"><MySource_PRINT var="asset_short_name" /></a><!--

–><MySource_SUB design_area=“menu_normal”>
<MySource_SET name=“settings.class.normal” value="" />
<MySource_SET name=“settings.class.current” value=“current” />
<MySource_SET name=“settings.class.hierarchy” value=“parent” />
<ul id=“subnav_<MySource_PRINT var=“asset_assetid” />” class=“a<MySource_PRINT var=“asset_assetid” /> subNav”><MySource_ASSET><li><a href="<MySource_PRINT var=“asset_link” />" class="<MySource_PRINT var=“settings.class” />"><MySource_PRINT var=“asset_short_name” /></a></li></MySource_ASSET></ul></MySource_SUB></MySource_ASSET>
</li></ul></nav></MySource_AREA>

It's slightly customised to give me the markup I need, but is this what you need? You can then customise the levels in the design customisations.


(Nic Hubbard) #3

Hi Nic, this is what I use for menus with subs:

 

<MySource_AREA id_name="menu_dropdown" design_area="menu_normal">
<MySource_SET name="show_subs" value="always" />
<MySource_SET name="settings.class.normal" value="" />
<MySource_SET name="settings.class.current" value="current" />
<MySource_SET name="settings.class.hierarchy" value="parent" />
<nav id="nav1" class="listNav"><ul> <!-- NAV1 -->
<MySource_ASSET><li id="nav_<MySource_PRINT var="asset_assetid" />" class="navLink"><a href="<MySource_PRINT var="asset_link" />" class="<MySource_PRINT var="settings.class" />"><MySource_PRINT var="asset_short_name" /></a><!--

–><MySource_SUB design_area=“menu_normal”>
<MySource_SET name=“settings.class.normal” value="" />
<MySource_SET name=“settings.class.current” value=“current” />
<MySource_SET name=“settings.class.hierarchy” value=“parent” />
<ul id=“subnav_<MySource_PRINT var=“asset_assetid” />” class=“a<MySource_PRINT var=“asset_assetid” /> subNav”><MySource_ASSET><li><a href="<MySource_PRINT var=“asset_link” />" class="<MySource_PRINT var=“settings.class” />"><MySource_PRINT var=“asset_short_name” /></a></li></MySource_ASSET></ul></MySource_SUB></MySource_ASSET>
</li></ul></nav></MySource_AREA>

It's slightly customised to give me the markup I need, but is this what you need? You can then customise the levels in the design customisations.

 

No, that doesn't work, that is listing all parents and all subs. I want to show the current parent and subs. Similar to what you get when you use level "top" and show_subs "always", but I don't want to show all top and subs. Just the current navigation section I am in.


(Tbaatar) #4

Is it even possible? I always wanted to figure this out but wasn't possible so I used 2 asset listing to crete the parent and child subs. Or just hide the other parents not related to the child.


(Nic Hubbard) #5

Is it even possible? I always wanted to figure this out but wasn't possible so I used 2 asset listing to crete the parent and child subs. Or just hide the other parents not related to the child.

 

I just figured it out. On top of each of my side subnav menus I also print another menu that shows all top pages, which I then hide using CSS. Then, based on what section they are in (the body tag has an ID for each section), I just show the corresponding top parent item. Works exactly how I was needing.


(Talk) #6

Yikes, I thought it’d be as easy as setting the wrapping menu to current and the sub menu to children. Glad you found a solution mate.


(Nic Hubbard) #7

Yikes, I thought it'd be as easy as setting the wrapping menu to current and the sub menu to children. Glad you found a solution mate.

 

No, because that would only show the current page and its siblings.


(Robin Shi) #8

 

No, that doesn't work, that is listing all parents and all subs. I want to show the current parent and subs. Similar to what you get when you use level "top" and show_subs "always", but I don't want to show all top and subs. Just the current navigation section I am in.

Hope i understand your question correctly, I used asset_lineage it works.

  <MySource_AREA id_name="single_parent_list" design_area="asset_lineage" print="no">
   <MySource_SET name="levels_to_print" value="-1" />
   <MySource_SET name="prefix_with_home_link" value="false" />
   <MySource_SET name="show_hidden_links" value="yes" />
   <MySource_SET name="suffix_with_current_link" value="false" />
   <MySource_SET name="prefix_with_divider" value="false" />
   <MySource_SET name="suffix_with_divider" value="false" />
   <MySource_SET name="unwanted_asset_types" value="user" />
   <MySource_SET name="reverse_lineage" value="false" />
   <MySource_ASSET> <a href="<MySource_PRINT var='asset_link' />">
   <MySource_PRINT var='asset_short_name' />
   </a></MySource_ASSET>
   </MySource_AREA> 

(Aleks Bochniak) #9

Yeh asset_lineage is the way to go.


(Nic Hubbard) #10

Yeh asset_lineage is the way to go.

 

Thanks guys. Will give it a try.