Welcome to ZTal.
Full documentation and examples are available at the ZTal github wiki
While Zend Framework is a powerful and useful framework for building MVC (Model / View / Controller) based PHP web application, it does have a few limitations and less-than-wonderful design aspects that make true MVC separation difficult to achieve and mixing of markup and PHP inevitable. Replacing the View and Form rendering components of Zend Framework with PHPTal (a fast and capable templating engine based on the Zope Template Attribute Language) it is much easier to keep full separation of markup and PHP while also benefiting from PHPTAL’s excellent translation and macro support.
ZTal provides the glue that allows Zend Framework to use PHPTAL templates as Views and Layouts while also allowing PHPTAL to access Zend Framework’s Translation facilities. In particular:
- ZTal replaces Zend View and Layout objects with PHPTAL equivalents.
- ZTal has macros to render Zend_Form and other common Zend objects such as Zend_Date and Zend_Currency.
- ZTal has access to Zend_Translate, unifying translation support.
- ZTal handles PHPTAL translation namespaces where they are not supported natively in Zend_Translate.
- ZTal provides plural support to PHPTAL’s translation capabilities.
- ZTal can use Zend_Cache to cache rendered PHPTAL pages.
- ZTal provides a Zend_Mail subclass to use templates with email.
By using a separate templating engine (especially one that makes use of PHP difficult) there is a clear distinction between the business logic and the display logic of your application. Pick the right templating engine and you can gain even more – easy template re-use, templates that can display placeholder output statically (i.e. without needing to run the php code while designing), easy translation support, better security and better standards compliance.
PHPTAL is a PHP implementation of the Zope Template Attribute Language (TAL). TAL is an XML-based language where template instructions are added to a layout in the form of attributes and tags. The original TAL document (with optional placeholder content) is a fully XML compliant document and the generated output is also fully XML compliant. PHPTAL takes care of correctly escaping variable content in many cases as well as setting the correct HTML attributes for ‘checked’, ‘selected’ and similar. PHPTAL includes localisation and internationalisation support right in at the core using a simple to use XML namespace allowing you to develop multi-lingual applications with very little effort and it has a powerful macro system allowing you to create libraries of display components for re-use across your application and applications. In addition, as a compiled-template technology, it is fully compatible with OpCode caches and PHP accelerators.