1

我有以下用于 october cms 的非常基本的插件,但我不知道如何使选项可编辑或确保插件与页面一起保存。我保存页面的那一刻,关闭它并重新加载它,横幅标题就消失了。

我查看了其他插件和示例,但我无法辨别我做错了什么..

插件.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'
        ];
    }
}

组件/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();
    }
   //...

}

?>

我遵循了天气应用教程中的每一步,逻辑有点规定这应该可以正常工作吗?Uncaught Error: Error parsing the Inspector field configuration. SyntaxError: Unexpected end of input 但是当我双击横幅框打开选项时,我进入了 javascript 控制台。

很明显有些地方出了问题,但这条神秘的信息并没有给我指明一个可以解决它的方向。

有谁知道我如何可以将其追溯到故障?或指出我正确的文件?其他插件工作正常,保存良好。

这可能是一些愚蠢而微小的事情。我只是想不通这是什么愚蠢的小东西。(有时我讨厌学习新东西,呵呵)

4

1 回答 1

2

只需添加$ret = new \stdClass();.

来源:无法编辑插件的属性,插件不会与页面一起保存

但是,stdClass是基于 PHP 的函数,而不是十月函数。错误可能会发生,但我不认为。

谢谢 (-:

于 2015-06-24T13:38:31.587 回答