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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:25:49
Script start
Timing: Jan 18 2025 18:25:49
Module start 'layout'
Timing: Jan 18 2025 18:25:49
Module start 'content'
Timing: Jan 18 2025 18:25:49
Module end 'content'
Timing: Jan 18 2025 18:25:49
Script end

Main resources:

Total runtime0.0133 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 587.8125152.6094
Module start 'layout' 0.00490.0024 740.421939.4141
Module start 'content' 0.00730.0039 779.835993.3203
Module end 'content' 0.01120.0021 873.156334.3047
Script end 0.0133  907.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002216.4918140.0002
Check MTime0.00107.6352140.0001
Mysql Total
Database connection0.00096.987710.0009
Mysqli_queries0.002216.265830.0007
Looping result0.00000.082510.0000
Template Total0.001712.410.0017
Template load0.00107.567010.0010
Template processing0.00064.821110.0006
Override
Cache load0.00075.543910.0007
General
dbfile0.00021.793680.0000
String conversion0.00000.053840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs