Link module tutorial - blockpress/blockpress.me GitHub Wiki

Folder

You must create a subfolder for your module in the module folder. Your folder name will be your module name, which must match in all other places where your module name is needed.

/module/your_module_name

JavaScript file.

You must create a JavaScript file inside this folder with the name your_module_name.js. For example, if you are creating a special link module to make it easier to link to Wikipedia pages, you might end up with something like:

/module/wikipedia/wikipedia.js

Menu Item Function

Function name

Your JavaScript file must contain a function with the name your_module_name_menuitem. (In other words append _menuitem to your_module_name for the name of the function.

Arguments Parameter.

As the module creator you can choose whether to accept strings, numbers, arrays and/or objects for the args parameter.

Return Value

The function must return the full url you intend to link to.

Example

The function inside our wikipedia example might look something like this:

/* Link module for wikipedia pages. For args we expect a string with the page name. */
function wikipedia_menuitem(args) {
    var page_name = args.replace(/\s/g,"_");
    return "https://en.wikipedia.org/wiki/"+page_name;
}

Back to Modules page