Prev |  | Next

### `phptal:tales`

This attribute allows us to change the behavior of PHPTALES. The default behaviors 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/property/10/othermethod/hashkey` takes relatively long to interpret (but don't worry about this too much – don't optimize until you find that it is really a problem with performance!)

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 object with a property; find that its value 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 object, 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().property[10].otherMethod().hashkey"></td></tr></table></body></html>

Please note that the above example does the same as:

                <html><body><table><tr tal:repeat="myobject php:document.getChildren()"><td tal:content="php:myobject.mymethod().property[10].otherMethod().hashkey"></td></tr></table></body></html>

#### Note

`php:` modifier is explained in its own chapter.

Prev | Up | Next
`phptal:cache` | Home | `tal:block`