How can I make my own plugin which has a setting page?



  • I added ./templates/admin/plugins/sort-by-votes.tpl. But it does not show at admin/plugin tab. What else thing should I do?

    This is my plugin.json:

    {
        "id": "nodebb-plugin-category-sort-by-votes",
        "name": "Sort by Votes",
        "description": "Adds functionality to sort topics by votes in category list view",
        "url": "https://bitbucket.org/wktang/nodebb-plugin-category-sort-by-votes",
        "library": "./library.js",
        "hooks": [
            {
                "hook": "filter:topics.get", "method": "addTopicsVotesInCategory"
            }
        ],
        "templates": "public/templates",
        "staticDirs": {
            "sortbyvotes": "public"
        }
    }
    

  • Community Rep

    Two things. You need to add the route and controller for that url, and you need to add a link to the admin header.

    Look at nodebb-plugin-quickstart

    Add the routes in the load hook. The controller function is defined here, here is also where you render the template and can add additional data if you wish.

    Use the hook filter:admin.header.build to add a link to the admin header. Like shown here.



  • @yariplus
    Thanks your tips works for me.


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.