skip to Main Content
How To Create A Dashboard Menu On NexoPOS

How to create a dashboard menu on NexoPOS

Now that you know how to create a module on NexoPOS, let’s see how to create a menu on the dashboard. By menu, we mean the sidebar menu available on the dashboard, which provide a quick access to some features.

How to register a menu on NexoPOS

Registering a menu can be made using the hook (filter) “admin_menus”. Note that, when we talk about hook, we mean the API Event, which let you trigger an action or filter data at a specific moment during the runtime of Tendoo CMS. Having your module set, here is how to register a menu.

https://gist.github.com/Blair2004/4bd212f3b61a1af12580b897f765a30c

The menu should look like this on the dashboard.

How to create sub menus on NexoPOS

If you want to group more that one menu together, you can then consider creating sub menus.¬† If a menu has more that one menu definition, then it’s assumed having sub menus. Using our previous example. We’ve created a menu with a single menu definition. In that case, the menu doesn’t have a sub menu. But to have sub menus, we need at least 2 menus definition like so.

https://gist.github.com/Blair2004/68ba2affc0a088dbb170acd407bb177e

Running this snippet will make the dashboard menu looks like this.

How to add a menu before or after a specific menu

Since all menus should have a namespace (or a name), you can then easilly use that name to inject your menu before or after that menu. You can use the function array_insert_before and array_insert_after¬†to inject your menu before or after a specific menu. Let’s use our previous menu and add it before the dashboard menu.

https://gist.github.com/Blair2004/31f9c983676ea57a07e0cee491646c9f

Here is what you have to know with the array_insert_before and array_insert_after.

  • The first parameter is the menu name (namespace) that you want to use as reference.
  • The second parameter is the actual menu array
  • The third is your menu name (namespace)
  • The fourth is your menu definition.

Running that snippets will make the dashboard looks like this.

How to retreive any menu namespace

You might now wonder, how can i get the name of an existing menu ? It’s simple. When you browse NexoPOS from you dashboard, you should be able to explore the source code of menu, which reveal the namespace (name) of the menu. Let’s do this with the menu “Modules”.

The module name is prefixed with a “namespace-“. To the actual module name is “modules”. You can then use that to add before or after a menu for your module.

Leave a Reply

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

Back To Top