• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.1 Latest
Buy Hosting

Not works filter:homepage.get

Scheduled Pinned Locked Moved NodeBB Plugins
getfilter0.7.0devhomepage
9 Posts 2 Posters 3.4k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    wrote on last edited by sergej-saveljev
    #1

    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!

    1 Reply Last reply
    0
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    wrote on last edited by
    #2

    I need to sort by category name on the main page.

    1 Reply Last reply
    1
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #3

    I just added a new hook called filter:categories.build use that instead.

    filter:homepage.get is used for the admin site.

    1 Reply Last reply
    0
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    wrote on last edited by sergej-saveljev
    #4

    @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.

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #5

    Is your plugin activated?

    sergej-saveljevS 1 Reply Last reply
    0
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    replied to <baris> on last edited by
    #6

    @baris yes. The parse method works.

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #7

    And you are on the latest commit or https://github.com/NodeBB/NodeBB/commit/c4569d533db6861f4ae6df5bc6e10e409007d9a6 ?

    sergej-saveljevS 2 Replies Last reply
    1
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    replied to <baris> on last edited by
    #8

    @baris no 🙂

    1 Reply Last reply
    0
  • sergej-saveljevS Offline
    sergej-saveljevS Offline
    Cергей Савельев Plugin & Theme Dev
    replied to <baris> on last edited by
    #9

    @baris thanks!!!

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development