Not works filter:homepage.get
-
Nonebb v.0.7.0dev
plugin.json:{ "id": "nodebb-plugin-design", "name": "Plugin name", "url": "absolute URL to Github", "library": "./index.js", "staticDirs": { "images": "./public/images" }, "scripts": [ "./public/js" ], "less": [ "./public/less/style.less" ], "hooks": [ { "hook": "filter:category.get", "method": "parse" }, { "hook": "filter:homepage.get", "method": "init" } ] }
index.js:
(function(module) { "use strict"; var cat = {}, async = module.parent.require('async'); cat.init = function(params, callback) { console.log(params); callback(); }; cat.parse = function(params, callback) { params.category.children = JSON.parse(JSON.stringify(params.category.children).replace(/(123 |456 |789 )/g, '')); function sortByKey(array, key) { return array.sort(function(a, b) { var x = a[key]; var y = b[key]; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }); }; params.category.children = sortByKey(params.category.children, 'name'); callback(null, params); }; module.exports = cat; }(module));
./nodebb dev in output of nothing
I've tried almost all of the filters, but I can not get a list of the categories of the home page. Please, help me! -
I need to sort by category name on the main page.
-
@baris said:
filter:categories.build
I tried it, and try again now, in the output of dev mode nothing. This works in subcategories, but not on the home page.
-
@baris yes. The parse method works.
-
@baris no
-
@baris thanks!!!
Copyright © 2024 NodeBB | Contributors