Answer the question
In order to leave comments, you need to log in
How to make twig extension in opencart 3?
Good afternoon, don't ask me why I needed this, but I need to write a small extension for twig. in opencart3 (and I don’t really rummage in twig)
for this, in system/library/template/Twig/Extension/ I created the RrequestUrl.php file with the inherited Twig_Extension class, here is the content.
<?php
/*
* This file is part of Twig.
*
* (c) 2012 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Extension_RequestUrl extends Twig_Extension
{
public function getFunctions()
{
return array(
new Twig_SimpleFunction('request_uri', 'request_uri'),
);
}
public function getName()
{
return 'request_uri';
}
}
function request_uri()
{
return $_SERVER['request_uri'];
}
$this->addExtension(new Twig_Extension_Core());
$this->addExtension(new Twig_Extension_Debug());
$this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
$this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
$this->addExtension(new Twig_Extension_RequestUrl());//мое расширение
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question