Accessing data inside header.tpl?
-
@Michael-Joseph-Aubry Well, you'd access the NodeBB api directly and add the data to the header object.
-
Since I am displaying recent first,
/api
shows an object with topics not categories. -
@Michael-Joseph-Aubry No, I mean adding the data on the server side with Node.
require
the categories and listen to this hook, adding the data. -
@pitaj said:
quire the categories and listen to this hook, adding the d
Ahh that makes more sense, so inside my theme.js I can have a method that uses node to pull in the categories and expose it. Ok so I guess I have to dig up some examples, do you have any examples on github that is similar?
-
GitHub - NodeBB/nodebb-plugin-custom-homepage: Allows you to define a custom homepage for NodeBB
Allows you to define a custom homepage for NodeBB. Contribute to NodeBB/nodebb-plugin-custom-homepage development by creating an account on GitHub.
GitHub (github.com)
That's a plugin that uses hooks. It doesn't use this specific hook as far as I know, but the hooks all work the same.
-
@Michael-Joseph-Aubry check out nodebb-plugin-quickstart (search it on Google)
-
@pitaj Ok well I keep seeing this
nodebb-plugin-quickstart/library.js at master · NodeBB/nodebb-plugin-quickstart
A starter kit for quickly creating NodeBB plugins. - nodebb-plugin-quickstart/library.js at master · NodeBB/nodebb-plugin-quickstart
GitHub (github.com)
plugin.addAdminNavigation = function(header, callback) { header.plugins.push({ route: '/plugins/quickstart', icon: 'fa-tint', name: 'Quickstart' }); callback(null, header); };
I just dont get how the server passes data to the client, I am looking at all the source code I can find including the example but there is nothing obvious about this? Can someone please just tell me how to simply pass something from library.js to the client?
-
Here is what I have done, I finally figured out how to get a list of categories, I kind of like this method but I hate having to pass an array, but it is what it is.
var theme = {}; var catLength = [1,2,3,4,5,6,7]; var Categories = module.parent.require("./Categories"); theme.init = function(params, callback) { Categories.getCategoriesData(catLength, function(err, data) { data.forEach(function(something, index) { if(something) { console.log(data[index].name); } }); }); callback(); }; module.exports = theme;
Cool now I have all the categories and the next step is to create a dynamic header based on the categories, the problem is I am so confused on how to do that, I think I am missing something very obvious!
I am inside a theme and I want to pass this into the precompiled template!