Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============

Expand Down
4 changes: 4 additions & 0 deletions news/+document-portlet-renderer.documentation.rst
Original file line number Diff line number Diff line change
@@ -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