Add a plugin
Create a new plugin with its own menu item, screen and API action.
On this page
The quickest way to add a plugin is to copy the sample plugin Profiles and rename it. This recipe builds a plugin called Orders.
1. Copy the sample
Copy the folder plugins/profiles to plugins/orders, and rename the file schemas/profiles.js to schemas/orders.js:
cp -R plugins/profiles plugins/orders
mv plugins/orders/schemas/profiles.js plugins/orders/schemas/orders.js2. Describe the plugin
Replace the content of plugins/orders/index.js with:
exports.icon = 'ti ti-shopping-cart';
exports.name = '@(Orders)';
exports.position = 3;
exports.permissions = [{ id: 'orders', name: 'Orders' }];
exports.visible = user => user.sa || user.permissions.includes('orders');
exports.routes = [
{ url: '/orders/{id}/', html: 'detail' }
];
exports.install = function() {
ROUTE('+API ? -orders --> Orders/list');
};iconandnameare the menu item. Icons are Total.js icon classes that start withti ti-, such asti ti-box.positionsets the order in the menu.- The
ROUTEline makes the API actionordersavailable to the screen.
Every option is listed in Plugin options.
3. Write the action
Replace the content of plugins/orders/schemas/orders.js with:
NEWACTION('Orders/list', {
name: 'List of orders',
permissions: 'orders',
action: function($) {
var arr = [];
for (var i = 0; i < 3; i++)
arr.push('Demo order ' + (i + 1));
$.callback(arr);
}
});Here you read your real data, for example from the database.
4. Adapt the screen
In plugins/orders/public/index.html, change the three places that name the sample:
BREADCRUMB.add('@(Profiles)', NAV.url);becomesBREADCRUMB.add('@(Orders)', NAV.url);REDIRECT('/profiles/{0}/'.format(id));becomesREDIRECT('/orders/{0}/'.format(id));exports.tapi('profiles ERROR', ...becomesexports.tapi('orders ERROR', ...
In plugins/orders/public/detail.html, change @(Profiles) to @(Orders).
5. Restart and check
Restart Pluginable and sign in. Orders is in the side menu and on the home screen, and it lists the demo orders.

Next steps: