Forums / Setup & design / Example code for Treemenu operator?

Example code for Treemenu operator?

Author Message

Marco Zinn

Friday 30 January 2004 12:44:24 pm

Since 3.3-1, there is an "extendet treemenu operator" shipped with ezPublish.

From the Changelog:
- Extended treemenu operator to support offset and unlimited number of levels. It will also give information about the current selected items.

Does anyone have a working example of how to use the operator in a (pagelayout) template? With all features, of course (offset, show selected item)

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

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