NexoPOS is a growing web application designed as a module of Tendoo CMS. It’s currently used as a Point of Sale application and it’s available on CodeCanyon with a bunch of features. However, NexoPOS can’t fit all business (with all their needs). In order to make NexoPOS get closer to fit all businesses needs we need to provide more features to it. The only and the best way to add features to NexoPOS is to create a module. In this turorial, you’ll learn how to create a module for NexoPOS.

List of modules for Tendoo CMS

Creating a config.xml file for your module

It’s not actually right when we’re saying “create a module for NexoPOS“. The real statement is : “create a module for Tendoo CMS“, since NexoPOS is already a module of Tendoo CMS. Every Tendoo CMS modules has a config.xml, which describe the module details. The config has then his name, the author name, the dependency and the entry point. It’s also the place to define the localisation.

The most important here is the namespace and the entry point. They should be defined and for the namespace, it should be unique. The entry point is where Tendoo CMS will start the module. Let’s create some basic module now.

How to create a Hello World module

In order to help you having a great idea of how stuff works, let’s create a basic hello world module. So, we’re going to create a module which show a content when we access to a specific route. Note that, all theses modification should be made on an empty folder.

1 – Entry for the module

The entry basically contain a class (should have a class) which directly trigger and register actions and filters. Action and filters is the better way to inject/modify data or to get notified if something happen on the system. Tendoo CMS use a Hook system similar to the one on WordPress. So when Tendoo CMS bootstrap, various actions and filters get triggered. And if your entry point register a class which run right after the definition, is to register actions and filters before they happen.

Here is a basic example of how an entry point looks like:

2 – Route & Controller for the module

All route of a module are saved within a “routes.php” file which should be available at the root of the module. A route is then set using the global variable $Routes, which can used as route are defined on Laravel.

Routes.php is only valid for Dashboard Routes. which means you don’t have to use “/dashboard/” on your routes. That will automatically be added for you. So having “/hello/world” result in the following complete URL “http://yoursite.com/dashboard/hello/world”.

The controller “HelloWorldController” should be saved within the folder “controllers” available at the root of your module. It’s usual to name the file as the controller class name. So the file should be HelloWorldController.php. The text following the symbol “@” is actually a method within the controller.

Every controller should extend “Tendoo_Module”, which expose some API available for each controller. It’s also required to bootstrap the parent class on the constructmethod.

With the previous example, if you zip the project and install it as a module. Accessing to the URL will result in a white page with “Hello World”. Now, let’s see how to wrap that hello world within Tendoo CMS dashboard.

3 – Creating view for controller

In order to create content within Tendoo CMS, there is a GUI API available for that. The GUI helps you to create UI with columns. It won’t be covered here, we’ll just show a hello world text for now.

All view of a module should be saved within the folder “views” at the root of the module. The load method helps you to load various content, including module view. This method takes as first parameter the module namespace and as second the file name (without .php at the end). Obviously that means you can load view from another module, by just changing the namespace.

Now if you test your module, you’ll be able to see Hello World within Tendoo CMS module. That’s not all, but a starting point to create module for Tendoo CMS and NexoPOS.