diff --git a/four-creative.php b/four-creative.php index 472f033..f651fbd 100644 --- a/four-creative.php +++ b/four-creative.php @@ -5,5 +5,14 @@ use Grav\Common\Theme; class FourCreative extends Theme { - // Access plugin events in this class + public static function getSubscribedEvents() + { + return ['onTwigExtensions' => ['onTwigExtensions', 0]]; + } + + public function onTwigExtensions() + { + require_once __DIR__.DIRECTORY_SEPARATOR.'php'.DIRECTORY_SEPARATOR.'DirFilesExtension.php'; + $this->grav['twig']->twig->addExtension(new DirFilesExtension()); + } } diff --git a/php/DirFilesExtension.php b/php/DirFilesExtension.php new file mode 100644 index 0000000..432cfe8 --- /dev/null +++ b/php/DirFilesExtension.php @@ -0,0 +1,35 @@ +