i have created a twig extension to include a file php .. this file is a function return a code html that i want to append it to my twig template
i have respected the structure in the documentation of GRAV but it dosent work !!
here is my code :
`<?php
namespace Grav\Plugin;
class PhpIncludeTwigExtension extends \Twig_Extension
{
public function getName()
{
return 'PhpIncludeTwigExtension';
}
public function getFunctions()
{
return [
new \Twig_SimpleFunction('includeFile', [$this, 'exampleFunction'])
];
}
public function exampleFunction(string $file)
{
ob_start();
require_once(dirname(__FILE__).'./'.$file);
$content = ob_get_clean();
return $content;
}
}`
`
Les actualités sont extraites du site Digital Learning Academy
{{ includeFile('./../../getData.php') }}
Nous remercions particulièrement le site Digital Learning Academy by IL&DI et Philippe Lacroix
i have created a twig extension to include a file php .. this file is a function return a code html that i want to append it to my twig template i have respected the structure in the documentation of GRAV but it dosent work !!
here is my code :
`<?php namespace Grav\Plugin;
class PhpIncludeTwigExtension extends \Twig_Extension {
}`
`
Les actualités sont extraites du site Digital Learning Academy
{{ includeFile('./../../getData.php') }}Nous remercions particulièrement le site Digital Learning Academy by IL&DI
et Philippe Lacroix