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

Plugin Development
  • #1

    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
    #2

    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.

  • #3

    @yariplus
    Thanks your tips works for me.


Suggested Topics


  • 0 Votes
    11 Posts
    681 Views

  • 0 Votes
    18 Posts
    1187 Views

  • 3 Votes
    8 Posts
    2515 Views

  • 0 Votes
    1 Posts
    897 Views

  • 0 Votes
    1 Posts
    1293 Views

| | | |