PHP code example of mmx / twig
1. Go to this page and download the library: Download mmx/twig library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mmx / twig example snippets
$tpl = $modx->getOption('tpl', $scriptProperties);
$var = $modx->getOption('var', $scriptProperties);
if ($service = $modx->services->get('mmxTwig')) {
$service->addFilter(
new \Twig\TwigFilter('hello', static function($var) {
return $var . ' World!';
}
));
return $service->render($tpl, ['var' => $var]);
}
return '';