These attributes are not defined in TAL specifications, but are useful when working with PHPTAL.
This attribute toggles the activation of PHPTAL debugging for the content of the tag it is defined in.
The debug mode stores information like filename and source line number in the template, so exceptions thrown by incorrect path access will contains more information about where they where thrown.
<html>
<head>
...
</head>
<body>
<div id="menu">
...
</div>
<div id="leftPane" phptal:debug=""
tal:comment="this div seems buggy, keep
trace of where errors are thrown">
...
</div>
</body>
</html>
This attribute causes output of entire element (including its tag) to be cached on disk and not re-evaluated until cache expires.
Content of this attribute is duration (how long element should be kept in cache) written as number with 'd', 'h', 'm' or 's' suffix.
<div class="footer" phptal:cache="3h">...</div>
<div> will be evaluated at most once per 3 hours.
Duration can be followed by optional "per" parameter that defines how cache should be shared. By default cache is shared between all pages that use that template. You can add "per url" to have separate copy of given element for every URL.
<ol id="breadcrumbs" phptal:cache="1d per url">...</ol>
<ol> will be cached for one day, separately for each page.
You can add "per expression" to have different cache copy for every different value of an expression (which MUST evaluate to a string). Expression cannot refer to variables defined using tal:define on the same element.
<ul id="user-info" phptal:cache="25m per object/id">...</ul>
<ul> will be cached for 25 minutes, separately for each object ID.
Limitations:
phptal:cache blocks can be nested, but outmost block will cache other blocks regardless of their freshness.
You cannot use metal:fill-slot inside elements with phptal:cache.
This attribute allows us to change the behaviour of PHPTALES. The default behaviours is to interpret attribute expressions in a very ZPT way. But sometimes you just would like to have PHP there, and you end up using php: modifier everywhere.
Another problem concerning PHPTALES is the way PHPTAL has to interpret paths. For example, myobject/mymethod/10/othermethod/hashkey takes a very long to interpret.
PHPTAL has (at runtime) to take myobject and discover that it is an object; find out that 'mymethod' is a method of this object (rather than a variable), and then to call it; explore the result to determine that it is an array; find the 'ten' element of this array, and determine that it is an object; decide that othermethod is a method of this object (rather than a variable), and get the result of its execution; find that it is an associative array, and then retrieve the value for the key 'hashkey'.
Of course this was an extreme example and most of the time we don't care, because the process is fast enough. But what if this very long path is called inside a big tal:repeat ? D'oh! phptal:tales can help us here:
<html>
<body>
<table phptal:tales="php">
<tr tal:repeat="myobject document.getChildren()">
<td
tal:content="myobject.mymethod()[10].otherMethod()['hashkey']"></td>
</tr>
</table>
</body>
</html>
Well, I am not sure that the example above compiles, but you get the idea of what you can do with phptal:tales. All tal, metal, i18n paths will be plain PHP expressions.
Please note that the above example do the same as:
<html>
<body>
<table>
<tr tal:repeat="myobject php:document.getChildren()">
<td
tal:content="php:myobject.mymethod()[10].otherMethod()['hashkey']"></td>
</tr>
</table>
</body>
</html>
'php:' modifier is explained in its own chapter.