1

I have been staring at this all morning, comparing to other plugins online and cannot see why my plugin settings page never registers. I have verified the actual settings model is populated, but settingsHtml() is never called.

Anything obvious I have missed?

class Storefront extends Plugin
{
    public static $plugin;
    public $schemaVersion = '1.0.1';
    public $hasCpSettings = true;
    public function init()
    {
        parent::init();
        self::$plugin = $this;

       $this->setComponents([
        'tracking' => TrackingService::class,
       ]);

        Event::on(
            Plugins::class,
            Plugins::EVENT_AFTER_INSTALL_PLUGIN,
            function (PluginEvent $event) {
                if ($event->plugin === $this) {
                }
            }
        );

        Craft::info(
            Craft::t(
                'storefront',
                '{name} plugin loaded',
                ['name' => $this->name]
            ),
            __METHOD__
        );
    }
    public function hasCpSection()
    {
        return false;
    }
    public function hasSettings()
    {
        return true;
    }
    protected function createSettingsModel()
    {
        return new Settings();
    }

    protected function settingsHtml(): string
    {
        return Craft::$app->view->renderTemplate('storefront/settings',
            [
            'settings' => $this->getSettings()
            ]
        );
    }
}
  • You could try generating your plugin framework via pluginfactory.io -- it'll make sure all of your i's are dotted and t's are crossed. – andrew.welch Mar 21 '19 at 13:30
1

I overlooked the settings in composer.json to enable a settings page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.