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

Accessing plugin events from Quark

Started by Richard Hainsworth 8 years ago · 0 replies · 685 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 stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 3 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago