Add custom data in nodebb dashboard
-
I'm looking to add a custom field similar to the overview and login fields to display our custom tables. However, I'm having trouble finding a way to do that. We want to implement a table or analytics data based on groups or members. Is there a hook or method we can use to add our field to a specific table or graph on the dashboard?
-
@baris How can we modify or override the template at src/views/admin/partials/navigation.tpl without core changes? Via custom JS, we are not getting the element to append our element. Can you please explain how we can achieve that?
-
To override it you would create a nodebb plugin and put a template file at the same path. So in your plugin it would be
templates/admin/partials/navigation.tpl
then you would copy the file from core and make your changes.Another option is to just add a link in there via JS to do this add a js file in your plugin to include it on the acp page. The quickstart plugin has a sample https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/plugin.json#L20.
In that file you can select the correct element and insert a link like below.
$('#collapseDashboard .accordion-body').append(` <a class="btn-ghost-sm justify-content-start text-decoration-none" href="${config.relative_path}/admin/mycustomdashboard">My Custom Dashboard</a> `);
-
@baris Thanks, I have inserted my custom file name in the dashboard. However, the problem is that now I am unable to create a route for that. Whenever I click the button, it shows me an error.
I want src/controllers/admin/dashboard.js and src/routes/admin.js files to be overridden
-
Adding the menu item into the template doesn't create a express route, you have to do that separately. https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/library.js#L37 I suggest writing a plugin for that instead of ovewriting the core js files.