MenuItem provides a convenient way to generate and display dynamic navigation menus

Download

  1. from icoya website
  2. from zope.org

Introduction

MenuItem provides a dynamic way to generate and display complex menu structures as usually required for webpages.

  1. What is MenuItem

    MenuItem is a mix in zope object class, which can render dynamic menus. Each object represents one menu entry. MenuItem comes per default with one real useable object. This object is a MenuItem Folder or in shorts a MenuFolder. With this folder complex menu structures can be created easily in very short time. Just create some folder structure and you get the menu as well.

  2. How does it work

    The MenuItem is catalogue based. That means there is a menu catalog (ZCatalog), which holds all information of each MenuItem. Because of speed only the catalogue is accessed when a menu is rendered. Each MenuItem has several methods to display its own menu. These methods return a complete representation of the current menu based on the actual context as html. A PageTemplate can be used to customize the layout of the html menu. These PageTemplates are called MenuTemplates. The MenuTemplates consists of one single part of the menu, which repeats itself for each MenuItem. Then a menu is rendered each MenuItem renders itself with the MenuTemplate, The MenuTemplate calls the render method again if the object has sub items. By this way the complete recursive menu tree can be rendered if wanted (e.g. for a sitemap). This can cause performance issues at very high load, so the output of the render methods is cacheable with zope caching mechanisms.

  3. The menu rendering methods

    Each MenuItem comes with the following methods. Every single method returns a rendered html menu fragment. The output of the methods can be customized by certain parameters, which are described later in this document.

    • The Methods
      • def renderMenu( template, showParent, showHidden)

        This method returns a common menu. Starting from the menu root, the tree is followed till the current MenuItem. The sub items of the current object are also show, so a complete navigation is possible. Use this method to create tree like menus.

      • def renderSiteMap( template, showParent, showHidden)

        This method returns the complete menu tree starting from the top which everything expanded. This is commonly called a sitemap.

      • def renderSubLevel( template, showParent, showHidden)

        This method renders the actual objects sub items.

      • def renderOwnLevel( template, showParent, showHidden)

        This method renders all items on the same menu levels as the current object. This would be the same as here.aq_parent.renderSubLevel.

      • def renderMenuLevel( template, showParent, showHidden, level)

        This method renders the requested menu level level.

    • The parameters
      • template

        Takes the name or the object which should be used as MenuTemplate. If a string test would be given the id is computed as menuTemplatetest. (the menuTemplate string is added in front). That object must be loadable in the current acquisition tree.

      • showParent

        Takes 0 or 1 as integer value. Selects if the parent object should be displayed or not.

      • showHidden

        Takes 0 or 1 as integer value. Selects if MenuItems with the hidden property should be displayed or not.

      • level

        Defines as integer which menu level should be rendered. Only the renderMenuLevel method has this parameter.