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

Accessing plugin events from Quark

Started by Richard Hainsworth 8 years ago · 0 replies · 765 views
8 years ago

I created a new Theme based on Quark using devtools called mgc. Theme works fine.

In the simple generated file mgc.php I find the comment

TXT
// Access plugin events in this class

However, when I try the standard way, eg., as in a normal plugin, I get a theme error, viz.,

TXT
Template "@images/grav-logo.svg" is not defined in "partials/base.html.twig" at line 44.

This is clearly wrong since grav-logo.svg exists. And if I delete all of the extra functions, the Theme starts working again.

Some help about how to access Plugin events within a Theme file would help.

My work around so far is to create a new plugin to handle the functionality.

My mgc.php file is

PHP
<?php<?php
namespace Grav\Theme;

use Grav\Common\Theme;
use Grav\Common\Grav;
use Grav\Common\Plugin;
use Grav\Common\Twig\Twig;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\Session\Message;

class Mgc extends Quark
{
    // Access plugin events in this class
    public static function getSubscribedEvents()
    {
        return [
            'onFormProcessed' => ['onFormProcessed',0]
        ];
    }

    public function onFormProcessed(Event $e) {
        if ($this->isAdmin()) {
            $this->active = false;
            return;
        }
    }
}

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by FrViPofm, 4 weeks ago
4 474 2 weeks ago
Themes & Styling · by johan thomas, 5 years ago
1 800 3 weeks ago
Themes & Styling · by stuart young, 2 months ago
3 660 2 months ago
Themes & Styling · by Sebadamus, 3 months ago
5 680 2 months ago
Themes & Styling · by martynfoster735, 3 months ago
1 642 3 months ago