Global Template Variables

Plone defines a few useful global variables to use them in your templates

While writing templates for Plone, you will notice a set of variables you use more often, like the URL of the portal or the currently authenticated member.

For your convenience, Plone defines a few global template variables that are pulled into main_template via global_defines. Some of the most useful ones are:

portal
The portal object.
portal_url
The url of the portal.
member
The current user (None if user is anonymous)
checkPermission
A function to check if the current user has a certain permission in the current context, e.g. checkPermission('View portal content', context).
isAnon
True if the current user is not logged in.
is_editable
True if the current user has edit permissions in the context.
default_language
The default language of the portal.
here_url
The URL of the current object.

To see the full list list of these variables, see the docstring for globalize() in the interface Products.CMFPlone.browser.interfaces.IPlone.

 

Can this list be expanded and moved to its own documentation section?

Posted by Daniel Greenfeld at Apr 10, 2009 03:40 PM
I don't want to be directed to some off-site documentation or to source code such as http://dev.plone.org/[…]/interfaces.py#L199.

Instead I want something linked in the Top Navigation of Plone directing me to a page that links to a nicely formatted HTML document that Google picks up. I would be willing to contribute on such a page but would need guidance.

Can this list be expanded and moved to its own documentation section?

Posted by Israel Saeta Perez at Apr 10, 2009 03:56 PM
dev.plone.org is not off-site, it's still into plone.org ;-)

Anyway, I put a link to the code because the interface will always be up-to-date and list all available variables with their descriptions. But I'm not against listing them all in this page too if you think it's better.

If you want to contribute, I can grant you access to this page to let you update it accordingly. :-D

Thanks!