This tutorial explains the steps needed to create a custom navbar menu item ("CustomMenu") and the controller that will execute the functions desired when a user clicks on that menu item.
Step 1
Create a scope definition file.
custom/Espo/Custom/Resources/metadata/scopes/CustomMenu.json
Notice that the setting "entity" is set to false so Espo will not create a table or expect to find an entityDefs json script or create a database table "custom-menu", also notice that the setting "tab" is set to true, so the menu item will be available to add from Administration > User Interface panel.
Step 2
Create a clientDefs metadata file, to tell Expo which front end controller will contain the instructions to execute when a User clicks on the custom menu item.
custom/Espo/Custom/Resources/metadata/clientDefs/CustomMenu.json
Step 3
Create the front-end controller that will execute actions when a User clicks on the custom menu item
client/custom/src/controllers/custom-menu.js
Step 4
Create a language json script to make the custom scope label "human friendly" in your preferred language
custom/Espo/Custom/Resources/i18n/en_US/Global.json
Step 5
Clear cache and rebuild
Administration > Rebuild
Step 6
Add the new menu item to the side navbar
Administration > User Interface > Tab List (click "Add", select "Custom Menu" from the tab list options, position where you want it to appear, and click "Save")
Step 7
Reload the page
Step 1
Create a scope definition file.
custom/Espo/Custom/Resources/metadata/scopes/CustomMenu.json
Code:
{ "entity": false, "tab": true, "acl": "boolean", "aclPortal": true, "aclPortalLevelList": [ "all", "account", "contact", "own", "no" ], "disabled": false, "module": "Custom", "isCustom": true }
Step 2
Create a clientDefs metadata file, to tell Expo which front end controller will contain the instructions to execute when a User clicks on the custom menu item.
custom/Espo/Custom/Resources/metadata/clientDefs/CustomMenu.json
Code:
{ "controller": "custom:controllers/custom-menu", "color": "#00ff66", "iconClass": "fas fa-file-contract" }
Create the front-end controller that will execute actions when a User clicks on the custom menu item
client/custom/src/controllers/custom-menu.js
Code:
define('custom:controllers/custom-menu', 'controllers/base', function (Dep) { return Dep.extend({ // default action actionIndex: function (options) { alert("This Custom Menu is working fine !"); } }); });
Create a language json script to make the custom scope label "human friendly" in your preferred language
custom/Espo/Custom/Resources/i18n/en_US/Global.json
Code:
{ "scopeNames": { "CustomMenu": "Custom Menu" }, "scopeNamesPlural": { "CustomMenu": "Custom Menu" } }
Clear cache and rebuild
Administration > Rebuild
Step 6
Add the new menu item to the side navbar
Administration > User Interface > Tab List (click "Add", select "Custom Menu" from the tab list options, position where you want it to appear, and click "Save")
Step 7
Reload the page
Comment