Spanish Total.js
English
Documentation For AI agents
Contents

Plugin options

Every option that a plugin can set in its index.js.

.md GitHub
On this page

A plugin describes itself with exports.<option> lines in its index.js. This is the index.js of the sample Products plugin:

exports.icon = 'ti ti-box';
exports.name = '@(Products)';
exports.position = 1;
exports.permissions = [{ id: 'products', name: 'Products' }];
exports.visible = user => user.sa || user.permissions.includes('products');
exports.routes = [
    { url: '/products/{id}/', html: 'detail' }
];

exports.config = [
    { id: 'city', name: 'City', value: 23 }
];

exports.install = function() {
    ROUTE('+API   ?   -products    --> Products/list');
};

Options

OptionWhat it does
nameName in the menu, on the home tile and as the group title in Settings. @(...) marks the text for translation.
iconIcon in the menu and on the home tile, a Total.js icon class such as ti ti-box.
positionOrder in the menu and on the home screen. Lower numbers come first.
permissionsPermissions that the plugin offers to OpenPlatform, as a list of { id, name }.
visibleA function that gets the signed-in user and returns true when the user may see the plugin. The samples return true for the admin account (user.sa) and for users with the plugin permission.
hiddentrue keeps the plugin out of the menu and the home screen. See Remove a plugin.
routesExtra screens, as a list of { url, html }. See Add a detail page.
configSettings shown in Settings, as a list of { id, name, value }. See Add plugin settings.
importAn HTML file in public that is loaded into every page of the admin. The admin plugin uses it for the account button.
installA function that runs on start. Put the ROUTE lines of the plugin here.

ROUTE lines for actions

A line such as ROUTE('+API ? -products --> Products/list'); makes the action Products/list available to the screens under the name products:

  • + means only signed-in users can call it.
  • ? stands for the admin address, /admin/.
  • -products is a call without data; +products sends data to the action, as in +settings_save.
  • After --> comes the name of the action in schemas.

A screen calls it with exports.tapi('products', ...), and a script with a token.

Made in Europe