How to get the portlet-hash css class for the Calendar portlet assigned to a custom portlet manager?

I am trying to fix the monthly navigation of the calendar portlet assigned to the custom portlet manager. This manager is called from a specific page template with:

<div id="calendar"
    tal:content="structure provider:my.custom.portletmanager" />

Unfortunately, the manager does not display the hash shell for me, so I try to manually add the cssattr-portlethash css class to the above tag <div>to do the monthly navigation (refreshPortlet () needs this). I tried this:

from plone.portlets.utils import hashPortletInfo
class SectionHomeView(BrowserView):
    """SectionHome browser view
    """
    implements(ISectionHomeView)

    def __init__(self, context, request):
        self.context = context
        self.request = request

    @property
    def getHash(self):
        info = dict(manager = 'my.custom.portletmanager',
                    category = 'context',
                    key = '/my-section',
                    name = 'mycalendar',
                   )
        return hashPortletInfo(info)

Using this code, I get a hash, but calendar navigation still doesn't work. How can I access portlet information such as manager, category, key and name to calculate correctly?

, , column.pt plone.app.portlets.browser.templates ColumnPortletManagerRenderer (portlets/manager.py), , ( ..: ).

+5
1

, PortletManagerRenderer EditPortletManagerRenderer, , , :

class MyCustomPortletManagerRenderer(ColumnPortletManagerRenderer) :
    """ This custom version of ColumnPortletManagerRenderer points to a new 
    template so that HTML can be customised. 
    """
    adapts(Interface, IThemeSpecific, IBrowserView, IMyCustomPortletManager)
    template = ViewPageTemplateFile('column.pt')

    def can_manage_portlets(self):
        context = self._context()
        if not ILocalPortletAssignable.providedBy(context):
            return False
        mtool = getToolByName(context, 'portal_membership')
        return mtool.checkPermission("Portlets: Manage portlets", context)

class MyCustomEditPortletManagerRenderer(ContextualEditPortletManagerRenderer):
    """To allow edit support of the above.
    """
    adapts(Interface, IThemeSpecific, IManageContextualPortletsView, IMyCustomPortletManager)
    template = ViewPageTemplateFile('edit-column.pt')

column.pt :

<tal:block repeat="portlet options/portlets">
<div tal:attributes="class string:portletWrapper kssattr-portlethash-${portlet/hash};"
     tal:content="structure python:view.safe_render(portlet['renderer'])" />
</tal:block>
+4

All Articles