How to find the folder in which the portlet was defined?

I am creating custom versions of news and events portlets that will only display content elements located downstream where they are defined (and not on the adjacent one).

The idea is for certain groups on our site to be able to create news and event portlets that display only items from the folder hierarchy below.

In fact, I have changed

portal_state.navigation_root_path()

for

path='/'.join(context.getPhysicalPath())

in the request to the browse directory

The problem I ran into is that context.getPhysicalPath () is evaluated based on where the portlet is being viewed, and not where the portlet was defined. When someone moves downstream from a top-level group folder, they often end up with an empty or disappearing portlet.

How to find the folder where the portlet is listed to pass this as my context?

+4
source share
1 answer

I think you want __portlet_metadata__['key'] :

 (Pdb) self.context.restrictedTraverse(self.__portlet_metadata__['key']) <ATFolder at /plone/Members/test_user_1_> 
+4
source

All Articles