Can't edit properties of plugin and plugin won't save with page

190 views Asked by At

I have the following very basic plugin for october cms and I can't figure out how to make the options editable or make sure that the plugin gets saved with the page. The moment I save the page, close it and reload it the banner header is gone.

I've looked at other plugins and examples and I can't discern really what i'm doing wrong..

Plugin.php

<?php namespace MDibbets\BannerHeader;

use System\Classes\PluginBase;

class Plugin extends PluginBase
{

    public function pluginDetails()
    {
        return [
            'name'        => 'Banner Header',
            'description' => 'Provides content management for the banner header module.',
            'author'      => 'Michael Dibbets',
            'icon'        => 'icon-sun-o'
        ];
    }

    public function registerComponents()
    {
        return [
           '\MDibbets\BannerHeader\Components\BannerHeader' => 'bannerheader'
        ];
    }
}

components/bannerheader.php

<?php 
namespace MDibbets\BannerHeader\Components;

use App;
use Event;
use Backend;
use Cms\Classes\ComponentBase;
use System\Classes\ApplicationException;

class BannerHeader extends ComponentBase
{
    public function componentDetails()
    {
        return [
            'name'        => 'Banner Header',
            'description' => 'Places a nice big banner header on the page with the below settings.'
        ];
    }

    public function defineProperties()
    {
        return [
            'maintitle' => [
                'title'             => 'Main Title',
                'type'              => 'string',
                'default'           => 'Welcome'
            ],
            'subtitle' => [
                'title'             => 'Sub Title',
                'type'              => 'string',
                'default'           => 'you are'
            ],
            'content' => [
                    'title'             => 'The Content',
                    'type'              => 'string',
                    'default'           => 'xxxxxxxxxx'
            ]
        ];
    }
    public function info() {
        $ret = new stdClass();
        $ret->title = $this->property('title');
        $ret->subtitle = $this->property('subtitle');
        $ret->content = $this->property('content');
        return $ret;
    }
    public function onRun() {
        $this->page['bannerheader'] = $this->info();
    }
   //...

}

?>

I followed every step in the weather app tutorial, and logic kinda dictates this should work right? yet I get in javascript console Uncaught Error: Error parsing the Inspector field configuration. SyntaxError: Unexpected end of input when I double click the banner box to open the options..

So clearly something is wrong, but this cryptic message doesn't point me in a direction where I can solve it.

Does anyone know how I can trace this back to a fault? or point me to the proper documentation? Other plugins work fine and save fine.

It's probaly something stupid and small. I just can't figure it out what the stupid small thing is.(sometimes I hate learning new stuff heh)

1

There are 1 answers

0
Félix Desjardins On BEST ANSWER

Just add $ret = new \stdClass();.

Source: Can't edit properties of plugin and plugin won't save with page

But, stdClass is a PHP based function, and not a October function. Error could happen, but I don't think.

Thanks (-: