@pitaj Prior to running ./nodebb upgrade I always do apt-get-update apt-get-upgrade so the server is already fully updated.
If there is something else that NodeBB requires then it should be part of the nodebb upgrade command.
How in plugin to get page in which method is called?
var post = false,
category = false,
home = false;
mod.categoriesBuild = function(params, callback) {
home = true;
callback(null, params);
};
mod.categoryGet = function(params, callback) {
category = true;
callback(null, params);
};
mod.postParse = function(params, callback) {
post = true;
callback(null, params);
};
mod.widgetsGet = function(data, callback) {
if ( category ){
...
}
else if ( post ){
...
}
else if ( home ){
...
}
post = false,
category = false,
home = false;
callback(null, data);
};
This is my bad variant.
How get app
in any plugin methods?
Probably, it is possible to determine the pathname
received app
and use it to identify a resource open the client.
My goal is that want to display html with h1 and description blocks for pages categories, subcategories and the post pages on the basis of their field name
and description
.
I chose to use widgets. Maybe there is a right decision?
Thank you all for your attention !!! Problem was solved !!!
mod.widgetsGet = function(data, callback) {
template = data.templates[1].replace('.tpl', '');
if ( template == 'categories' ){
console.log('Home page opened');
}
else if ( template == 'category' ){
console.log('Subcategory page opened');
}
else if ( template == 'topic' ){
console.log('Topic page opened');
}
callback(null, data.data);
};
If I understand you correctly, It sounds like you should be adding this to your widget or theme.
I don't think adding a filter is what you want to do. Filters are used to modify data, an "action" would be better if you're trying to figure out when a specific widget area is requested. But, this would not be useful in this regard because it's also called on the ACP Widget page.
What you probably want to do is use the existing "filter:widget.render:widgetname" hook,
plugins.fireHook('filter:widget.render:' + widget.widget, {
uid: uid,
area: area,
data: widget.data
}
The area that is passed has area.template already.
@yariplus I can not understand why in the data that is returned fireHook only widget.data?
In the code src/widgets.js
file seems to be all right.
@sergej-saveljev That's okay, it is a little confusing. The hook returns uid, area, and data. For example, the function you would assign to "filter:widget.render:widgetname" would be like:
mod.renderWidget = function(data, callback) {
console.log(data.area.template); // This is the template you are looking for.
console.log(data.data); // This is the Widget's setting data.
console.log(data.uid); // This is the User who is viewing the page.
return callback();
}
@yariplus returned undefined
for all console.log calls
Did you create the widget? It won't work if there's no widget to render.
Do you have a link to your full code?
@yariplus said:
Did you create the widget? It won't work if there's no widget to render.
Do you have a link to your full code?
Yes, I created widget. I deleted code, but he was about, how you wrote.
Hmm, I'm not sure why it wouldn't work then, that's pretty much exactly my code.