Custom Module Help

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? :slight_smile:

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 ( 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:

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

    // Install and additional module files that are required.

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! :slight_smile:

Your HelloWorldModule.php shouldn’t be in its own folder, it just needs to be inside custom as far as I know.

As an aside, displays some static text… then add in a parameter where a user could enter a name or select a color option. can both be done with a simple dataset.

Thanks for the reply Alex. Here I was still trying to figure out how to fix the code blocks in the OP (apologies on that).

Eventually the Module will call some company-specific API information to show inside the module. I just wanted to start off with something simple (baby steps) and learn how things were laid out.

I tried moving the HelloWorldModule.php up to just being in the /custom folder, but no luck, same error message “Class Xibo\Custom\HelloWorldModule\HelloWorldModule not found”.

I’m not 100% sure I am in the right folders, but I imagined I was since the .json is obviously getting picked up. Maybe I missed something else?

I’m not sure I’m afraid, it’s not my area really. @Peter might be able to shed some light for you tomorrow.

1 Like

Your initial idea was correct, new modules should (not necessarily need to though, but it is cleaner) have their own folder inside the /custom path.

in the HelloWorldModule.php, the namespace should be

obviously that should be php file ie<?php should be at the top, not sure if that’s just copy/paste went wrong or if you don’t have it specified.

Aside from installOrUpdate(), each module should also have getResource($displayId = 0) (even if it does not need it, in such case it should return null) and isValid() (usually returns 1 ie valid or 2 if the client does the rendering).

If the module should have additional settings then settings() and settingsForm() will be required and of course the .twig file associated with the settingsForm.

Similarly, if it is a widget that will be added to the layout designer then you will want add() and edit() functions with the associated twig files would be needed.

If you do not see the problem, please send me the /custom folder in zip archive via private message and I can take a look.

Thanks for the reply Peter!

I got that namespace swapped and ensured it does say “<?php”. I also tried to trek on through the docs and now have a getResource function similar to the doc page. I opted to add in some settings with a mock API key like the examples (as I will likely end up using some API key anyway). So my structure is just as you suggest it should be: (my twig files are all lower case though if that might matter)

/custom/helloworldmodule.json /custom/HelloWorldModule/HelloWorldModule.php /custom/HelloWorldModule/helloworldmodule-form-add.twig /custom/HelloWorldModule/helloworldmodule-form-edit.twig /custom/HelloWorldModule/helloworldmodule-form-settings.twig

When i try to “Install Module” now… clicking “Install” seems to just hang and it never goes any further. Not quite sure what I should do from here :confused: I tried to PM you, but I don’t see an option to add a .zip file? I can upload it elsewhere and send you a link if that works for you…

I received your PM and I had a look at it now, I believe I’ve fixed the problems for you, more details in the pm from me :slight_smile:

Hello I’m trying to create a simple module to, but i don’t know how to do it.
Can you share your module in order to i have an example ?

Hi @Peter / @alex

It’s superb CMS for Digital signage. I would be appreciated if you can help me to solve the below error.
Can you please help to install custom module when I click install at that time I am getting the following error

jquery.js:9837 POST http://localhost/learn/xibo/web/module/inst/helloworldmodule 500 (Internal Server Error)
Using 2.0.3 version.