Jul 03, 2012
Plone of these days
We start from the typical use case of making a Plone page fit inside an iframe, than we'll see the many ways Plone page rendering process can be controlled by properly setting request parameters
Did you ever wanted...
... to just include the main content from a Plone page in an iframe and for this reason struggled with customized views and CSS rules to remove unwanted page elements like portlets, viewlets, footer and so on?
Did you know...
... that there is a simple and easy way to request Plone to serve a page with only the main content, skipping all the surrounding elements for navigation?
For the impatients
To embed a page inside an iframe, since Plone 4.0.3, you have the option to include just the main content by appending the query string: ?ajax_load=1&ajax_include_head=1, to the URL inside the src attribute.
<iframe width="480" height="200"
<iframe width="480" height="260"
The page displays the login form and the sitemap without all the elements that are not relevant for this use case (logo, headers, footer, portlets, viewlets and so on).
If you use a customized main template that is not aware of this technique you could have different results!
tl;dr AKA Toooo Long: Don't Read AKA Hic Sunt Leones
The parts of the page that "disappear", when request parameters are properly set, are not rendered at all by the server because the default main_template is "request aware". Looking at it (see sunburst main_template.pt on github) it is possible to understand in detail what is happening.
The ajax_load parameter, if set to a non null value, disables the rendering of many sections of the template (e.g. portal_top, viewlets and the portlet columns).
The ajax_include_head forces the plone.head provider to be rendered even if the ajax_load parameter would remove it from the page.
Since Plone 4, there is also the chance to disable portlet columns by adding the request parameter ?disable_$NAME=1, where $NAME is the portlet manager (e.g. plone.leftcolumn or plone.rightcolumn). So the url to disable both the left and right column will be something like this:
relevant code: take a look to the have_portlets method.
In many ZPT templates those request parameters are enforced using dummy defines:
Take a look (e.g.) to the dashboard page template.
The capability of Plone to disable template parts by request is not a prerogative of Plone 4. For example, for years now, setting the parameter ?disable_border=1, it is possible to remove the "green bar" on top of the views (the one that appears when you are logged in and let's you add/modify contents and make some more actions).
Do you know...
... any other trick like those?