Forums / Setup & design / menu and submenu

menu and submenu

Author Message

Marcin N.

Tuesday 12 December 2006 12:25:12 am

Hi!

I have menu (folders). Now I try to build submenu (folders). Menu and submenu are placed separate in diffrent parts of site. When you click menu item then you get site with submenu (kind of context submenu) for clicked item (just one level depth nothing more).
Now I used this standard code:

{let docs=treemenu( $module_result.path,
                    is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),
                    ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                    0, 5 )
                    depth=1
                    last_level=1}
        <ul>
        {section var=menu loop=$:docs last-value}
            {set last_level=$menu.last|is_array|choose( $menu.level, $menu.last.level )}
            {section show=and( $last_level|eq( $menu.level ), $menu.number|gt( 1 ) )}
                </li>
            {section-else}
            {section show=and( $last_level|gt( $menu.level ), $menu.number|gt( 1 ) )}
                </li>
                    {"</ul>
                </li>"|repeat(sub( $last_level, $menu.level ))}
            {/section}
            {/section}

            {section show=and( $last_level|lt( $menu.level ), $menu.number|gt( 1 ) )}
                {'<ul><li>'|repeat(sub($menu.level,$last_level,1))}
                <ul>
                    <li class="menu-level-{$menu.level}">
            {section-else}
                <li class="menu-level-{$menu.level}">
            {/section}

            <a {$menu.is_selected|choose( '', 'class="selected"' )} href={$menu.url_alias|ezurl}>{$menu.text|shorten( 25 )}</a>

            {set depth=$menu.level}
        {/section}
           </li>

        {section show=sub( $depth, 0 )|gt( 0 ) loop=sub( $depth, 0 )}
            </ul>
        </li>
        {/section}
        </ul>

{/let}

..but it doesn't work as I want. It shows whole structure (I want items on the second level) and it doesn't change when I click main menu :/
'll be thankful for tips examples etc. ...!?

Marcin

Marcin N.

Tuesday 12 December 2006 4:06:32 am

I started again with much more simple code:

{def $mainMenu=treemenu( $module_result.path, $module_result.node_id, , 1, 3 ) }

{foreach $mainMenu as $menu}

<li class="level_{$menu.level}">
 
    {if $menu.is_selected}
        <div class="selected">
        <a href={$menu.url_alias|ezurl}>{$menu.text}</a>
        </div>
    {else}
        <a href={$menu.url_alias|ezurl}>{$menu.text}</a>
    {/if}
</li>

{/foreach}

{undef $mainMenu}

It works BUT...my submenu doesn't change when I click main menu item :(

Marcin N.

Tuesday 12 December 2006 5:58:50 am

I put my submenu code in cache-block:

{cache-block keys=$module_result.node_id}
...
{/cache-block}

... but still nothing

Claudia Kosny

Wednesday 13 December 2006 12:29:41 pm

Hi Marcin

Could you give an example what you want to accomplish and what the structure of the site is? Example:
Structure of the site:
-mainfolderA
--subfolderA1
--subfolderA2
--subsubfolderA2i
--subsubfolderA2ii
--subsubfolderA2iii
--subfolderA3
-mainfolderB
--subfolderB1
--subfolderB2
-mainfolderC
--subfolderC1
--subfolderC2
--subfolderC3

The menu on the main page should look like:
...

and when clicking on mainfolderA, the menu should look like:
...

Claudia

Marcin N.

Thursday 14 December 2006 12:33:25 am

Thanks for help!
I found solution here:
http://ez.no/community/forum/setup_design/new_menu
there is my answer.

Marcin