Using Other Information about your Site on a Page

How to get information about the state of your site and other global variables.

At some point or other you'll find you need to use the title of your site in a template; or you'll want your template to deliver something depending on the roles or permissions of your visitor or user. There are two approaches for obtaining this information:

2.  Global Defines (deprecated)

The second approach has been around for a long time, but is being phased out (as it is slower) in Plone 3 and has been pretty much removed in Plone 4. This is to use a set of variables that are available to every single page.

In Plone 3:

These are called by main_template:

<metal:block use-macro="here/global_defines/macros/defines" />

If you want to investigate them further, you'll find them in

  • [your products directory]/CMFPlone/browser/ploneview.py.

These variables are used in a number of the default Plone templates in Plone 3 and so they are listed below alongside their equivalent in the available views.

In Plone 4:

The global_defines macro is not used at all and the variables have been entirely replaced in all Plone templates. However, should it be required, the global_defines macro is still available in the core Plone Default skin layers in the plone_deprecated folder.  For more information on making a Plone 3 theme compatible with Plone 4, consult the upgrade guide.

Available Views and Methods

About the site

View @@plone_portal_state

Method

What you get

global defines

portal

Portal Object

portal

portal_title

The title of your site

portal_title

portal_url

The URL of your site

portal_url

navigation_root_path

Path of the navigation root

navigation_root_url

The URL of the navigation root

navigation_root_url

default_language

The default language of the site

language

The current language

locale

The current locale

is_rtl

Whether the site is being viewed in an RTL language

isRTL

member

The current authenticated member

member

anonymous

Whether or not the current visitor is anonymous

isAnon

friendly_types

Get a list of types that can be deployed by a user

About the current context

View @@plone_context_state

Method

what you get

global defines

current_page_url

The URL of the current page

current_page_url

current_base_url

The actual URL of the current page

canonical_object

The current object itself

canonical_object_url

The URL of the current object

view_url

The URL used for viewing the object

view_template_id

The id of the view template

is_view_template

True if the current URL refers to the standard view

object_url

The URL of the current object

object_title

The 'prettified' title of the current object

workflow_state

The workflow state of the current object

wf_state

parent

The direct parent of the current object

folder

The current folder

is_folderish

True if this is a folderish object

isFolderish

is_structural_folder

True if this is a structural folder

isStructuralFolder

is_default_page

True if this is the default page in a folder

is_portal_root

True if this is the portal root or the default page in the portal root

is_editable

True if the current object is editable

is_editable

is_locked

True if the current object is locked

isLocked

 actions (Plone 4)

The filtered actions in the context. You can restrict the actions to just one category.

 portlet_assignable (Plone 4)

 Whether or not the context is capable of having locally assigned portlets.

Tools

view @@plone_tools

method

what you get

global defines

actions

The portal actions tool

atool

catalog

The portal_catalog tool

membership

The portal_membership tool

mtool

properties

The portal_properties tool

syndication

The portal_syndication tool

syntool

types

The portal_types tool

url

The portal_url tool

utool

workflow

The portal_workflow tool

wtool