How send var from method to method

  • Plugin & Theme Dev

    Please, tell me how send variable or array from method in to other method? For example, I create method hook filter:category.get and I want send to method hook filter:widgets.getAreas or how in my example filter:widgets.frontGetAreas. I can not find the solution.

  • Plugin & Theme Dev

    I need get category name and put to widget html. I do this as follows:

        "id": "nodebb-plugin-myplugin",
        "name": "Plugin name",
        "url": "Path to Github",
        "library": "./index.js",
        "staticDirs": {
            "images": "./public/images"
        "scripts": [
        "less": [
        "hooks": [
            { "hook": "filter:category.get", "method": "categoryGet" },
            { "hook": "filter:widgets.frontGetAreas", "method": "widgetsGet" }

    filter:widgets.frontGetAreas it's my fireHook.

    (function(module) {
    	"use strict";
        var cat = {},
            category = false,
    		home = false;
        cat.categoryGet = function(params, callback) {
    		category = params;
            callback(null, params);
        cat.widgetsGet = function(data, callback) {
    		var header = JSON.parse(data[0].header),
    			headernew = [];
    			if ( == 456 ){
    			 = '<h1>''</h1>'; += '<p>'+category.category.description+'</p><p>&nbsp;</p>';
    		data[0].header = JSON.stringify(headernew);
            callback(null, data);
    module.exports = cat;

    Look at this nonsense)))

    I have an idea, I'll try to implement.

  • Plugin & Theme Dev

    My idea is not universal. I would like to know the universal solution.

  • GNU/Linux

    In order for your code to work you have to be sure that 1) categoryGet and widgetGet are always called in context of the same request and 2) none of them are called with another request in between.

Suggested Topics

| |