skip to Main Content
How To Create A NexoPOS Module To Add More Features

How to create a NexoPOS module to add more features

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.

https://gist.github.com/Blair2004/916e3525f37bc0f3f307b241b781deff
Example of module configuration

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:

https://gist.github.com/Blair2004/cb35d22e073263fc0a7c7281eeb81d2f
Entry Point

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.

https://gist.github.com/Blair2004/87b1fca93fd36825646fcc2effbb7932
Defining routes

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.

https://gist.github.com/Blair2004/f3f93fef1fe6ba28c3956c5a211087a9
Hello World 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 construct method.

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.

https://gist.github.com/Blair2004/11bff6094cb1bfff3cb87ca8d35c64dd
Updating Controller

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.

https://gist.github.com/Blair2004/45d75eb227f183970fcc9684f059a815
helloworld.php

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.

This Post Has One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top