[z3-five] Menu and MenuItem in Five

Maciej Wisniowski maciej.wisniowski at coig.katowice.pl
Thu Oct 19 21:44:20 CEST 2006


>> Is this possible somehow to get these menu items to be
>> visible in ZMI just like standard tabs?
>
> Short answer: no.
>
> Long answer: Of course, but it's very complicated. :)
Seems that I didn't know that it is complicated and I did this... ;)
I've just defined filtered_manage_options function for my content
class like:

-------------------------
from zope.app import zapi

class MyClass(SimpleItem):

  (...)

  def filtered_manage_options(self, REQUEST=None):
        """test...
        """
        options = SimpleItem.filtered_manage_options(self, REQUEST)
       
        # it is Zope2.8 so we have to use getView instead of getMultiAdapter
        view = zapi.getView(self, 'view_get_menu' ,self.REQUEST)
        view = view.__of__(self)
        five_options = view['zmi_views']

        for d in five_options:
            #change title to label
            d['label'] = d.get('title', '')

            options.append(d)
        return options
-------------------------




configure.zcml:
-------------------------
<browser:page
      for=".interfaces.IMyClass"
      template="nope.pt"
      name="cos_tam.html"
      permission="zope2.Public"
   />

    <browser:menu
        id="zmi_views"
        title="blaa"
    />

    <browser:menuItem
        menu="zmi_views"
        title="cos_tam"
        for=".interfaces.IMyClass"
        action="cos_tam.html"
        permission="zope2.Public"
        />
-------------------------




and my page template nope.pt:
-------------------------
<p metal:use-macro="here/generic/macros/genericHeader">Generic Header</p>
print nopeee
<p metal:use-macro="here/generic/macros/genericFooter">Generic Footer</p>
-------------------------



Did I miss something here??

-- 
Maciej Wisniowski


More information about the z3-five mailing list