Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Plugins

Twig Template Paths

first-time

Started by Arpega 7 years ago · 0 replies · 526 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 Rene, 1 week ago
2 49 1 week ago
Plugins · by Xavier, 4 weeks ago
2 57 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1184 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 50 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 75 2 months ago