(TAL テンプレート言語)

Description

Plone uses TAL template language for its templates. This document contains references to this template language and generally available templates, macros and views you can use to build your Plone add-on product.

はじめに

Plone uses TAL template language which has METAL extensions for macros. TALES expressiong

Plone 3 has two kind of template

  • View page templates. They have associated view template variable. These templates live under browser/ folder structure in your add-on product. You can override them by <browser:page> ZCML directive.
  • Old style page templates. They live under plone_skins structure in ZMI and. You can override them by register a new plone_skins layer. The most infamous of them is main_template which provides skeleton for all Plone themes.

See browser:page

TAL

TAL is template language used Plone. TAL is XML based language, which puts programming logic to XML attributes.

Escaped and unescaped content

By default, all TAL output is escaped for the security reasons.

view.text = "<b>Test</b>"
<div tal:content="view/text" />

Will output escaped HTML source code:

&lt;b&gt;Testlt;/b&gt;

Unescaped content can be outputted using tal:replace attribute and structure.

<div tal:replace="structure view/text" />

Will output unescaped HTML source code:

<b>Test</b>

METAL

METAL is TAL extension to provide macros and slots to the template language.

Using METAL macros is no longer recommended, since they couple programming logic too tightly with the template language. You should use views instead.

Read more about in TAL Guide.

TALES expressions

TALES expressions are condition clauses used in TAL templates and various other parts of Plone

  • CSS, Javascript and KSS registries whether to include a particular file
  • Action conditions whether to show or hide action link
  • Workflow security guards whether to allow workflow state transition
  • etc.

Read more about expressions in TAL Guide.

See Expressions chapter for more information.

Overriding templates for exising Plone views

  1. New style templates can be overridden by overriding the view using the template.
  2. Old stype templates can be overridden by register a new skins layer in plone_skins

Old style page template

  • Create a new layer in portal_skins
  • Templates are resolved by their name and portal_skins properties sets the priority which add-on product is looked for the first
  • Reorder layers for the active theme so that your layer thakes priority (see Properties tab on portal_skins)

Portlet slots

By default, Plone main_template has slots for left and right portlets. If you have a view where you don’t explicitly want to render portlets you can do

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
        xmlns:tal="http://xml.zope.org/namespaces/tal"
        xmlns:metal="http://xml.zope.org/namespaces/metal"
        xmlns:i18n="http://xml.zope.org/namespaces/i18n"
        lang="en"
        metal:use-macro="here/main_template/macros/master"
        i18n:domain="plone">

        <head>
                <metal:block fill-slot="column_one_slot" />
                <metal:block fill-slot="column_two_slot" />
        </head>

Edit frame

By default, Plone draws green edit frame around the content if you can edit it. You might want to disable this behavior for particular views.

Hiding the edit frame

If you’d like to hide the (green) editing frame place the following code to your Zope 2 like page template:

<metal:block fill-slot="top_slot"
               tal:define="dummy python:request.set('disable_border',1)" />

Examples of this usage