Hi everyone!
We are interested in making a few custom modules to use in Xibo for our signs. I’m having a little trouble / confusion getting set up. Hopefully someone can point us in the right direction?
We’ve got 1.8.11 up and running, locally hosted, via the Docker installation.
I’d just like to start with a “Hello World” Module that just displays some static text… then add in a parameter where a user could enter a name or select a color option.
I’ve been trying to follow the documentation here (https://xibo.org.uk/manual/en/advanced_modules.html) as well as I’ve ended up on different forum posts, but I’ve not had much luck yet in getting this off the ground.
I’m working in this directory:
/opt/Xibo/xibo-docker-1.8.11/shared/cms/custom/
This seems to be the right place, as adding the helloworldmodule.json to that folder gives me the option to Install it on the Modules Page.
So in that folder I have helloworldmodule.json
{
"title": "Hello World Module",
"author": "Wendi Borden",
"description": "A test of the module system",
"name": "helloworldmodule",
"class": "Xibo\\Custom\\HelloWorldModule\\HelloWorldModule"
}
I then have a sub-folder for my Module: /custom/HelloWorldModule
With a file named HelloWorldModule.php
<?
namespace Xibo\Custom\HelloWorldModule\HelloWorldModule;
use Respect\Validation\Validator as v;
use Xibo\Entity\Media;
use Xibo\Exception\NotFoundException;
use Xibo\Factory\ModuleFactory;
use Xibo\Widget\ModuleWidget;
class HelloWorldModule extends ModuleWidget
{
protected $codeSchemaVersion = 0.1;
/**
* Install or Update this module
* @param ModuleFactory $moduleFactory
*/
public function installOrUpdate($moduleFactory)
{
if ($this->module == null) {
// Install
$module = $moduleFactory->createEmpty();
$module->name = ‘Hello World Module’;
$module->type = ‘helloworldmodule’;
$module->class = ‘Xibo\Custom\HelloWorldModule\HelloWorldModule’;
$module->description = ‘A first module for testing the module system’;
$module->imageUri = ‘forms/library.gif’;
$module->enabled = 1;
$module->previewEnabled = 1;
$module->assignable = 1;
$module->regionSpecific = 1;
$module->renderAs = ‘html’;
$module->schemaVersion = $this->codeSchemaVersion;
$module->settings = [];
$module->viewPath = ‘…/custom/HelloWorldModule’;
$module->defaultDuration = 60;
// Set the newly created module and then call install
$this->setModule($module);
$this->installModule();
}
// Install and additional module files that are required.
$this->installFiles();
}
Now there is about as far as I know to go. I’m still a bit confused on what files I need (and where they should reside). If I try to “Install Module” right now I get “Class Xibo\Custom\HelloWorldModule\HelloWorldModule not found”
Is there some kind of Skeleton Module / initial folder structure / something I could look at to get some idea or how this should be setup?
I did find the built-in modules on my system and started to look them over. I thought modifying the text module might be the simplest? I’m just not sure where to start. Any pointers on where to go from here would be wonderful! Thanks to all!