Example code for Treemenu operator?

Example code for Treemenu operator?

Friday 30 January 2004 12:44:24 pm - 3 replies

Modified on Friday 30 January 2004 12:44:57 pm by Marco Zinn

Author Message

Paul Borgermans

Friday 30 January 2004 2:42:10 pm

Hi Marco

Try the following in your pagelayout, it shows a tree of folders and highlights where you are for all folders starting from the second level of your node tree.

It expects an array with node id's, the noded id you currently are, a filter array with class names, the depth to skip from the root level and the max levels of depth to show. I suggest to always use the first two argemunts like below in a pagelayout template.

A warning: always pass a filter array, the treemenu operator otherwise falls back to classes with ids 1 and 8. YMMV

{* This code is copyright 2038 on mars by polleke and is a stripped version from the book *}
        <div style="width: 150px; border: solid 1px black; padding-top: 1em;">
            <ul>
                {let menuLevel2=treemenu($module_result.path,$module_result.node_id,array('folder'), 1, 5 )}
                    {section name=Menu loop=$menuLevel2}
                        <li style="margin-left: {$:item.level}0px;
                                {section show=$:item.is_selected}color: red;{/section}">
                           <a href={$:item.url_alias|ezurl}
                                {section show=$:item.is_selected} style="color: red;"{/section}>
                                {$Menu:item.text|shorten(50)}</a>
                        </li>
                    {/section}
                {/let}
            </ul>
        </div>

Put some nice cache-block around it and tell me if you like it

- paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Paul Borgermans

Friday 30 January 2004 2:54:55 pm

O yeah,

Currently the treemenu operator uses hard-coded sorting on priority. So for consistency, do this with your folders too.

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Marco Zinn

Saturday 31 January 2004 2:36:43 am

Thanks a lot Paul, i will try this ASAP.

Marco
http://www.hyperroad-design.com

You must be logged in to post messages in this topic!

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