[Product-Developers] Hiding portlet when there is no data to display.

Espen Moe-Nilssen espen at medialog.no
Mon May 26 07:16:49 UTC 2008


Probably not the way to do it, but could you solve it by using a  
viewlet and then have an if expression on it ?

   tal:condition="here/data | nothing"  />





Den 30. apr. 2008 kl. 20.43 skrev Arno Blumer:

> Hallo,
>
> I have made a custom portlet in Plone 3 that displays Cost  
> Estimates/Quotes in certain states under certain
> circumstances.
> The query is such that it wil sometimes return an empty list.
> Just like Plone's Events portlet, it should not display when the  
> list is empty, i.e. when there are no quotes to display.
> Also, since it is the only portlet in the right hand column, the  
> whole column should not display when the portlet is empty,
> just like with the Events portlet.
>
> I have tried using
> @property
> def available(self):
>     return len(self._data())
>
> but this causes an AttributeError on renderer.available in def  
> _lazyPortlets:
>
> @memoize
> def _lazyLoadPortlets(self, manager):
>     retriever = getMultiAdapter((self.context, manager),  
> IPortletRetriever)
>     items = []
>     for p in self.filter(retriever.getPortlets()):
>         renderer = self._dataToPortlet(p['assignment'].data)
>         try:
>             isAvailable = renderer.available
>
> Is this the right way to go about making sure the portlet and  
> column does not display when the portlet's data list is empty?
> If so, how do I give my Renderer class the "available" property, so  
> that I don't get the AttributeError?
>
> At the moment I have placed a condition around my portlet template,  
> to check whether there is data to display.
> This hides the portlet, but doesn't get rid of the column with the  
> "Manage portlets" link.
> (Also, I don't want to place conditions in the main_template.)
>
>
>
>
>
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20080526/138568b3/attachment-0002.html>


More information about the Product-Developers mailing list