From 164088b1e55bc95fe15e22390c49b8a3f77e4ef2 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 1 Jun 2026 12:09:02 +0200 Subject: [PATCH 1/4] Document the @@render-portlet view. Documentation about the @@render-portlet view, which can be used to reload a portlet via AJAX. --- docs/classic-ui/portlets.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/classic-ui/portlets.md b/docs/classic-ui/portlets.md index ee1aca0170..130ba6b199 100644 --- a/docs/classic-ui/portlets.md +++ b/docs/classic-ui/portlets.md @@ -40,7 +40,7 @@ As a user, you can add a portlet to a web page in a Plone site by following thes If you do not see the {guilabel}`Manage portlets` link, you may need to contact the site administrator to request access. 3. In the {menuselection}`Add portlets` menu, select the portlet type that you want to add, and click the {guilabel}`Add` button. - This will open a form to edit the settings for the selected portlet type. + This will open a form to edit the settings for the selected portlet type. 4. Click the {guilabel}`Save` button to save your changes and add the portlet to the web page. This adds the portlet to the list of {guilabel}`Portlets assigned here` on the screen. @@ -50,7 +50,6 @@ As a user, you can add a portlet to a web page in a Plone site by following thes The {guilabel}`X` button deletes the portlet. These options will only appear at the root from which the object inherits its settings. - ## Writing a custom Portlet To create a portlet, you will need to write Python classes that define the portlet and its behavior. @@ -202,3 +201,31 @@ These values should match the corresponding classes and interfaces defined in th This file registers the `MyPortlet` class as a portlet with Plone. It also specifies the portlet's name, title, description, and category. For more examples of how to write and register portlets, look at the source code of the Plone core package [`plone.app.portlets`](https://github.com/plone/plone.app.portlets), or of other Plone add-ons that include portlets. + +## Calling a single portlet via a URL + +To call a portlet by its URL, for example to update it via an AJAX call, you +can use the `@@render-portlet` view in your portlet renderer with a +`portlethash` as query parameter. + +The following example shows how to construct a reload URL for a portlet:: + +```python +from plone.app.portlets.portlets.base import Renderer +from Products.CMFPlone.utils import safe_unicode + + +class BasePortletRenderer(Renderer): + @property + def hash(self): + portlethash = self.request.form.get( + "portlethash", getattr(self, "__portlet_metadata__", {}).get("hash", "") + ) + return portlethash + + @property + def reload_url(self): + base_url = self.context.absolute_url() + hash = safe_unicode(self.hash) + return f"{base_url}/@@render-portlet?portlethash={hash}" +``` From 21c403da82949db30a30baa111148d914dc23740 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 1 Jun 2026 15:47:41 +0200 Subject: [PATCH 2/4] Update docs/classic-ui/portlets.md Co-authored-by: Steve Piercy --- docs/classic-ui/portlets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/classic-ui/portlets.md b/docs/classic-ui/portlets.md index 130ba6b199..01977647eb 100644 --- a/docs/classic-ui/portlets.md +++ b/docs/classic-ui/portlets.md @@ -208,7 +208,7 @@ To call a portlet by its URL, for example to update it via an AJAX call, you can use the `@@render-portlet` view in your portlet renderer with a `portlethash` as query parameter. -The following example shows how to construct a reload URL for a portlet:: +The following example shows how to construct a reload URL for a portlet. ```python from plone.app.portlets.portlets.base import Renderer From 66b45a78333b694d667e7f870191926519628f1b Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 1 Jun 2026 15:48:34 +0200 Subject: [PATCH 3/4] Update docs/classic-ui/portlets.md Co-authored-by: Steve Piercy --- docs/classic-ui/portlets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/classic-ui/portlets.md b/docs/classic-ui/portlets.md index 01977647eb..9a4a2321b5 100644 --- a/docs/classic-ui/portlets.md +++ b/docs/classic-ui/portlets.md @@ -202,7 +202,7 @@ This file registers the `MyPortlet` class as a portlet with Plone. It also speci For more examples of how to write and register portlets, look at the source code of the Plone core package [`plone.app.portlets`](https://github.com/plone/plone.app.portlets), or of other Plone add-ons that include portlets. -## Calling a single portlet via a URL +## Call one portlet by URL To call a portlet by its URL, for example to update it via an AJAX call, you can use the `@@render-portlet` view in your portlet renderer with a From 127cdd54516ff87f36b12d702d252b4fa7022081 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 1 Jun 2026 15:49:10 +0200 Subject: [PATCH 4/4] Update docs/classic-ui/portlets.md Co-authored-by: Steve Piercy --- docs/classic-ui/portlets.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/classic-ui/portlets.md b/docs/classic-ui/portlets.md index 9a4a2321b5..e447598d06 100644 --- a/docs/classic-ui/portlets.md +++ b/docs/classic-ui/portlets.md @@ -204,9 +204,7 @@ For more examples of how to write and register portlets, look at the source code ## Call one portlet by URL -To call a portlet by its URL, for example to update it via an AJAX call, you -can use the `@@render-portlet` view in your portlet renderer with a -`portlethash` as query parameter. +To call a portlet by its URL, for example, to update it via an AJAX call, use the `@@render-portlet` view in your portlet renderer with `portlethash` as a query parameter. The following example shows how to construct a reload URL for a portlet.