PHPTAL tries to use best defaults possible and you shouldn't need to change any of the settings.
All of these are methods of the PHPTAL
class. set
methods return instance of their class, so you can chain them:*
<?php
echo $phptal->setPhpCodeDestination('/tmp/phptal')->setOutputMode(PHPTAL::XML)->setTemplate('tpl.zpt')->execute();
?>
то же самое, что и:
<?php
$phptal->setPhpCodeDestination('/tmp/phptal');
$phptal->setOutputMode(PHPTAL::XML);
$phptal->setTemplate('tpl.zpt');
echo $phptal->execute();
?>
setEncoding(
: Specify what encoding your templates use. The default is UTF-8.encoding
)
setOutputMode(
: If given mode
)PHPTAL::XHTML
(the default), will output elements like <img>
, <link>
, and attribtes like checked
, selected
according to XHTML specification, including HTML compatibility guidelines. Use PHPTAL::XML
if you want to output other XML formats, like Atom or RSS.
setTemplateRepository(
: Specifies where to look for templates. If given a string, it adds it to the list of paths searched. If given array, it replaces the list.string_or_array
)
This doesn't mean all your files need to be in the root directory, you can use sub folders to organize your template designer's work. It's just a shortcut which will allow you to reference templates without specifying the real path, but instead their relative path within the repository.
setPhpCodeDestination(
: To tell PHPTAL where to store its intermediate (temporary) PHP files. By default it uses directory given by PHP's path
)sys_get_tmp_dir()
, which usually is '/tmp/
' directory.
setPhpCodeExtension(
: What filename extension should be used for intermediate PHP files. The default is string
)php
and frankly, there's no reason to change it.
setCacheLifetime(
: Maximum number of days intermediate files and fragments cached with num_days
)phptal:cache
should be kept.
setForceReparse(
: forces reparsing of all templates all the time. This slows down PHPTAL very much, it should be used only for testing and debugging. Never enable this on production servers.boolean
)
There are other set
methods for filters, internationalization, etc. They have been described in other sections of this manual.*