All modules are located in gotoAndPlay/Modules/
.
All modules must extend class gotoAndCore\Models\Module
and have a public static function getFields
defined.
The public static function getFields
method is used to add fields under the module. Method must return an array whose keys will be used to access the values.
To create an option field, add is_option
as true
to field settings.
<?php
namespace gotoAndPlay\Modules;
use gotoAndCore\Models\Module;
use gotoAndCore\Fields\Text;
use gotoAndCore\Fields\TrueFalse;
use gotoAndCore\Fields\Wysiwyg;
class Content extends Module {
public static function getFields() {
return [
'title' => new Text(),
'content' => new Wysiwyg(),
'showTitle' => new TrueFalse([
'is_option' => true,
]),
];
}
}
To add the created module as a dynamic module we must extend class gotoAndCore\Models\Layout
.
In addition to getFields
method we need to define getName
method to tell which module from our pattern library we want to use.
The getLabel
method is optionally used to tell the admin UI to show a custom label for the module. If no getLabel
method is defined the module label will be generated from the class name.
To reorder template order in the admin UI, define protected $layoutOrder = 2;
instance variabel on your module.
<?php
namespace gotoAndPlay\Modules;
use gotoAndCore\Fields\Wysiwyg;
use gotoAndPlay\Models\Layout;
class Content extends Layout {
protected $layoutOrder = 2;
public function getName() {
return 'content-1-1';
}
protected function getLabel() {
return 'Content 1/1';
}
public static function getFields() {
return [
'content' => new Wysiwyg(),
];
}
}