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.

Themes & Styling

Accessing plugin events from Quark

Started by Richard Hainsworth 8 years ago · 0 replies · 603 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 Pedro M, 2 months ago
4 202 2 months ago
Themes & Styling · by Ian, 2 months ago
3 98 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 461 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 52 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 132 3 months ago