Wallogit.com
2017 © Pedro Peláez
A Smarty Module for Zend Framework 2. As of 0.3, it is now compatible with Zend Expressive as well, but your package must will require zendframework/zend-expressive-zendviewrenderer, or that you select Zend View Manager as your renderer during the Zend Expressive quick set up.., (*1)
This package is designed to properly implement Smarty into the Zend Framework, unlike other approaches this one mimics the way ZF 2 works. It creates View Model, Strategy, and Renderers and provides factories to them., (*2)
You need to change all of your template names in your module.config.php to point at .tpl files. The .tpl extension will trigger the
Smarty view rendering strategy and everything will work as you want. Access to $this inside the smarty file is doable via
{$renderer}. For example, <a href="{$renderer->url('object/edit', ['id' => 1234])}">., (*3)
Regular Smarty limitations apply, which makes it not always easy to change a phtml file to a tpl file. You can pass functions in and call them via {call_user_func...}, and you can pass in arrays but they must use square bracket syntax {if in_array(4, [1,2,3,4])}., (*4)
composer require ryanknu/zendsmarty will download this package.composer require smarty/smarty will get you the latest version. Zend\Expressive\Template\TemplateRendererInterface::class =>
ZSmarty\Factory\StrategyFactory::class,