Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Accessing plugin events from Quark

Started by Richard Hainsworth 8 years ago · 0 replies · 715 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, 15 hours ago
1 30 2 hours ago
Themes & Styling · by stuart young, 1 month ago
3 480 1 month ago
Themes & Styling · by Sebadamus, 2 months ago
5 481 2 months ago
Themes & Styling · by martynfoster735, 2 months ago
1 460 2 months ago
Themes & Styling · by Justin Young, 2 months ago
1 490 2 months ago