[Zope3-Users] Menus

Jim Washington jwashin at vt.edu
Mon Feb 19 07:46:31 EST 2007


David Johnson wrote:
> I am curious what methods people use to implements simple web site 
> menus?  It seems to be this must be a common task.
>
> So far I've done this as follows:
> 1. Create a skin
> 2. Create a content type Menu as Ordered Container
> 3. Create a content type MenuItem as contained by Menu
> 4. Add a Menu and fill it with MenuItems
> 4. Register Menu
> 5. Create a macro which returns the Menu using zapi.getUtility()
> 6. Use the macro in the skin, and display all the MenuItems.
>
Hi, David

You can do it that way.

I've been successful with the browser:menu... directives in zcml.  The 
following, as part of my browser/configure.zcml file, actually creates 
an IBrowserMenu utility with a name of "myMenu".  I have another set of 
menuItems for the same menu for different interfaces, so the same named 
menu has different items at different parts of the site.

I find it handy to have this configuration in the same file where I 
configure the names of the pages.

<!-- name the menu -->
   <browser:menu
        id="myMenu"
        title="Main menu"
         />
        
<!-- MAIN MENU -->
<browser:menuItems
        menu="myMenu"
        for="..interfaces.IMainInterface"
        >
    <browser:menuItem
        title="Main Page"
        action="/index.html"
        permission="zope.Public"
        />

    <browser:menuItem
        title="About Us"
        action="aboutus.html"
        permission="zope.Public"
       />
</browser:menuItems>

- Jim Washington


More information about the Zope3-users mailing list