Hi sylvio,
I also had to strip the '@@' prefix in the view_methods declaration to
make my own choosable view appear in the menu.
I believe that this is a bug and that Plone should normaly be able to
display the choosable views even if they are declared with the prefix.
Additional info: if you want your view to appear in the menu with a
human readable title instead of its raw id, you have to declare it in
your configure.zcml file this way:
----- configure.zcml ------------
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="plone">
<browser:menuItems
for="*"
menu="plone_displayviews"
>
<browser:menuItem
title="View One"
action="view1"
description="Specific view for specific content type"
/>
</browser:menuItems>
</configure>
---------------------------------
- 'action_id': the id of the view as you declared it in the generic
setup profile, in 'view_methods' (without the '@@' prefix as it was
stripped in the GS profile).
- 'title': the name of the view that will be displayed in the menu
- 'description': the description of the view that will be displayed when
the mouse hovers the item in the menu.
Hope this helps…
David
Silvio wrote:
Hi all
I am developing a custom content-type that should have some user-selectable
views
(as in "atct_album_view" and so on) available in the standard "Display"
Plone menu.
I just spent some hours to figure out why they didn't appear in the menu.
The fact was that they were browser views (so @@view1 and @@view2).
I solved it aliasing my views to strip the @@ part.
In profiles/default/types/mytype.xml:
<property name="view_methods">
<element value="view1"/>
<element value="view2"/>
</property>
<alias from="@@view1" to="view1"/>
<alias from="@@view2" to="view2"/>
I don't know if this is supposed to be the right way as I couldn't fully
understand the code from method getAvailableLayouts of
CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin
Should I register two adapters with name="@@view1" and name="@@view2"?
If so, can someone tell me the exact syntax?
Thanx
SIlvio
here is the code from CMFDynamicViewFTI.browserdefault.BrowserDefaultMixin:
def getAvailableLayouts(self):
...
method_ids = fti.getAvailableViewMethods(self)
for mid in method_ids:
view = zope.component.queryMultiAdapter((self, self.REQUEST),
zope.interface.Interface,
name=mid)
if view is not None:
menu = zope.component.getUtility(
IBrowserMenu, 'plone_displayviews')
item = menu.getMenuItemByAction(self, self.REQUEST, mid)
... # add the view to the available ones
method = getattr(self, mid, None)
if method is not None:
... # add the view to the available ones
------------------------------------------------------------------------
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers