imponeer / smarty-xo
Smarty template engine plugins collections based on ideas for plugins from XOOPS
Installs: 19 658
Dependents: 3
Suggesters: 1
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- imponeer/smarty-extensions-contracts: ^1.0 || ^2.0
README
Smarty XO
Rewritten (due licensing issues) collection Smarty plugins that where originally written for Xoops but now can be used everywhere.
Installation
To install and use this package, we recommend to use Composer:
composer require imponeer/smarty-xo
Otherwise, you need to include manually files from src/
directory.
Registering in Smarty
If you want to use these extensions from this package in your project you need register them with registerPlugin
function from Smarty. For example:
$smarty = new \Smarty(); $plugins = [ new \Imponeer\Smarty\Extensions\XO\XOAppUrlCompiler( function (string $url): string { // function that converts url into path return $url; }, function (string $url, array $params = []): string { // function that adds params to path return $url . '?' . http_build_query($params); } ), new \Imponeer\Smarty\Extensions\XO\XOPageNavFunction( function (string $url): string { // function that generates real url return $url; }, $strPreviousPage = '<', $strNextPage = '>', $oldSchoolUrlMode = true ), new \Imponeer\Smarty\Extensions\XO\XOImgUrlCompiler( function (string $imgPath): string { // function that makes psiaudo path into real assets path return $imgPath; } ), new \Imponeer\Smarty\Extensions\XO\XOInboxCountFunction( function (): ?int { // function that calc unread messages in user inbox return 0; } ) ]; foreach ($plugins as $plugin) { if ($plugin instanceof \Imponeer\Contracts\Smarty\Extension\SmartyFunctionInterface) { $type = 'function'; } else { $type = 'compiler'; } $smarty->registerPlugin($type, $plugin->getName(), [$plugin, 'execute']); }
Inspirations list
This list can be useful for comparing current plugins code with original version to see differences and find some useful data how to use these plugins.
How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try interactive GitHub tutorial.
If you found any bug or have some questions, use issues tab and write there your questions.