diff --git a/README.rst b/README.rst index 09e6915a..82a10d61 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,34 @@ plone.app.portlets provides a Plone-specific user interface for plone.portlets, as well as a standard set of portlets that ship with Plone. +Call one portlet by URL +======================= + +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:: + + 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}" + + Compatibility ============= diff --git a/news/+document-portlet-renderer.documentation.rst b/news/+document-portlet-renderer.documentation.rst new file mode 100644 index 00000000..bc87746a --- /dev/null +++ b/news/+document-portlet-renderer.documentation.rst @@ -0,0 +1,4 @@ +Document the @@render-portlet view. +Documentation about the @@render-portlet view, which can be used to reload a +portlet via AJAX. +@thet