Search code examples
ploneplone-4.x

Plone 4: Get the parent of a page in a portlet template


I have something like: site/country-1/item-1/item-2/item-3

In Item 3 I have a portlet. In its template I'm trying to show the title of Item 2 or Item 1. How can I do this?

<div tal:content="python:context.Title()"></div> gives me Item 3.

<div tal:content="python:context.aq_parent"></div> gives me <plone.app.portlets.portlets.classic.Renderer object at 0x7fa76b97a990>

<div tal:content="python:view"></div> the same: <plone.app.portlets.portlets.classic.Renderer object at 0x7fa76b97a590>

I need this information to implement a solution to have news items and events filtered by parent country, on any level.


Solution

  • The acquisition chain may be different from what you expect. To see the acquisition chain check context.aq_chain.

    You may have good luck trying context.aq_inner.aq_parent. Anyway I would use the plone_context_state view, i.e.: context/@@plone_context_state/parent.

    Relevant links: