Forums / Developer / Open Tree Menu in left of the page

Open Tree Menu in left of the page

Author Message

C G

Thursday 23 November 2006 4:19:45 am

Hi,

I'm new to ez publish and I want to change the menu behavior a little bit.

Now for example the left menu is something like this:

Categ_1
--------------------------
Categ_2
---------------------------
Categ_3

and when you click on "Categ_1" link will became:

Categ_1
______Categ_1_1
______Categ_1_2
______Categ_1_3
--------------------------
Categ_2
---------------------------
Categ_3

Now whatI I want to do is that when the menu is loaded into the page it should look like this:
Categ_1
______Categ_1_1
______Categ_1_2
______Categ_1_3
--------------------------
Categ_2
______ Categ_2_1
______Categ_2_2
______Categ_2_3
---------------------------
Categ_3
______Categ_3_1

This mean that each level/sub-lecel menu must be visible without clicking on parent level.

Thx.

Wise concepts for the right customer
http://www.blankconcept.com

Jacobo Quiles

Thursday 30 November 2006 3:11:21 am

Hi,

You could try something like this:

{def $second_level_children=array()}
{def $root_node_children=fetch('content', 'list', hash('parent_node_id', 2))} {* <-- node 2 is home, but can be any other node *}

{if gt($root_node_children|count,0)}
    <ul>
    {foreach $root_node_children as $child}
        <li>
            <a href={$child.url_alias|ezurl()}>{$child.name|wash()}</a>
            {set $second_level_children=fetch('content','list',hash('parent_node_id', $child.node_id))}
            {if gt($second_level_children|count,0)}
                <ul>
                {foreach $second_level_children as $child2}
                    <li><a href={$child2.url_alias|ezurl()}>{$child2.name|wash()}</a></li>
                {/foreach}
                </ul>
            {/if}
        <li>
    {/foreach}
    </ul>
{/if}

First fetch the elements of the top level, foreach element check if it has children, if so, show its children.

Cheers.

Microblau SL
http://www.microblau.net

C G

Sunday 03 December 2006 5:16:42 am

Hi Jacobo,

thx for your replay. I tested and work ok.

My problem is that I want to use flat_left.tpl layout and I don't know how to change it to work in the same way as your code.

My template code is below, maybe you can help me with it.

{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=0}
        <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}

Wise concepts for the right customer
http://www.blankconcept.com

Jacobo Quiles

Monday 04 December 2006 12:48:48 am

Hi C G, just replace the code in your flat_left.tpl with my code, it should work fine.
The problem i think it comes from the treemenu function that is not fetching any node. Just replace all the code with mine and see if it works.

Microblau SL
http://www.microblau.net

C G

Monday 04 December 2006 12:59:10 am

Hi Jacobo,

Your code is working fine, I wrote that above. The probem with your code is regarding nodes priorities. In admin page a set some node priorities and I don't know how to use them in your code.

Any ideas?

Wise concepts for the right customer
http://www.blankconcept.com

Jacobo Quiles

Monday 04 December 2006 2:43:09 am

Hi, you mean set a sort by priority in admin interface and show the elements acording with the priority set?

Try this:

{def $second_level_children=array()
      $root_node=fetch('content','node',hash('node_id',2))
      $root_node_children=fetch('content', 'list', hash('parent_node_id', $root_node.node_id, 'sort_by', $root_node.sort_array))}

{if gt($root_node_children|count,0)}
   <ul>
   {foreach $root_node_children as $child}
       <li>
           <a href={$child.url_alias|ezurl()}>{$child.name|wash()}</a>
           {set $second_level_children=fetch('content','list',hash('parent_node_id', $child.node_id))}
           {if gt($second_level_children|count,0)}
               <ul>
               {foreach $second_level_children as $child2}
                   <li><a href={$child2.url_alias|ezurl()}>{$child2.name|wash()}</a></li>
               {/foreach}
               </ul>
           {/if}
       <li>
   {/foreach}
   </ul>
{/if}

Sorry if i missunderstand but my english is not very good.

Cheers.

Microblau SL
http://www.microblau.net

C G

Tuesday 05 December 2006 12:15:41 am

Hi Jacobo,
your code is working great.

Thx again.

Wise concepts for the right customer
http://www.blankconcept.com

eZ debug

Timing: Jan 18 2025 05:04:20
Script start
Timing: Jan 18 2025 05:04:20
Module start 'content'
Timing: Jan 18 2025 05:04:21
Module end 'content'
Timing: Jan 18 2025 05:04:21
Script end

Main resources:

Total runtime0.7319 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 587.7344180.8281
Module start 'content' 0.00610.6095 768.5625602.9063
Module end 'content' 0.61560.1162 1,371.4688345.0547
Script end 0.7318  1,716.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.5540210.0002
Check MTime0.00150.2075210.0001
Mysql Total
Database connection0.00080.104810.0008
Mysqli_queries0.647388.44542060.0031
Looping result0.00180.25172040.0000
Template Total0.702796.020.3513
Template load0.00200.267420.0010
Template processing0.700795.741420.3503
Template load and register function0.00030.041110.0003
states
state_id_array0.00120.163810.0012
state_identifier_array0.00090.122320.0004
Override
Cache load0.00170.2387670.0000
Sytem overhead
Fetch class attribute can translate value0.00130.173830.0004
Fetch class attribute name0.00110.148180.0001
XML
Image XML parsing0.00090.126430.0003
class_abstraction
Instantiating content class attribute0.00000.0029100.0000
General
dbfile0.00590.8119280.0002
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 32
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs