Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Twig Template Paths

first-time

Started by Arpega 7 years ago · 0 replies · 727 views
7 years ago

Hi,

I try to make a new plugin, but i can't collect his template.

The code is really minimalist and there is no other files than files created by devtools (SSH) and the folder "templates/single-product.html.twig".
However, the template doesn't appears when i try to create a page with this template.

I rode a lot of similar topics and docs but i do not have more idea.

Thank you!

PHP
<?php
    namespace Grav\Plugin;

    use \Grav\Common\Plugin;
    use RocketTheme\Toolbox\Event\Event;

    /**
     * Class ModelePlugin
     * @package Grav\Plugin
     */
    class ModelePlugin extends Plugin
    {
        /**
         * @return array
         *
         * The getSubscribedEvents() gives the core a list of events
         *     that the plugin wants to listen to. The key of each
         *     array section is the event that the plugin listens to
         *     and the value (in the form of an array) contains the
         *     callable (or function) as well as the priority. The
         *     higher the number the higher the priority.
         */
        public static function getSubscribedEvents()
        {
            return [
                'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0]
            ];
        }

        public function onTwigTemplatePaths()
        {
            $this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
        } 
    }
last edited 10/15/19 by Arpega

Suggested topics

Topic Participants Replies Views Activity
Plugins · by complanar, 2 weeks ago
6 366 2 weeks ago
Plugins · by BenLaKnet, 2 weeks ago
1 182 2 weeks ago
Plugins · by complanar, 1 month ago
2 465 4 weeks ago
Plugins · by Vladimir Novak, 2 months ago
3 748 2 months ago
Plugins · by Mathieu Lecouturier, 2 months ago
3 585 2 months ago