@Ted & @esiao
I wonder if you may share some experience on it? I am working on a similar thing but haven't get a clear clue how this could be done. Thanks!
@Ted & @esiao
I wonder if you may share some experience on it? I am working on a similar thing but haven't get a clear clue how this could be done. Thanks!
@julian Thanks, I will pull and merge the latest master now. Thanks for the quick response
I am planning writing a plugin that can customize the composer due to our applications need.
The thing I am trying to do is splitting the main composer to two parts: content and reference and store them separately for search purpose, since our forum is related to some research topics so we need to make sure that users are aware that they need to fill that part.
I really appreciate if anyone familiar with the composer may tell me which module might be affected in this case, especially I really care much about the modules related to search functionality. It is kind of complicate since this is the core functionality of nodebb and there are so many related modules. I am still digging around the code to see how things got wired up and hopefully I can get some helps from you.
If I am not on the right track or you may have some better ideas around this topic, just feel free to tell me. Thanks so much!
@baris Great hint acutally!
I traced down to the hook.js and see how things got wired up.
So it happens when I called plugins.fireHook('filter:search.render', params, callback)
, where callback as I posted in the first place only takes one parameter results.
So in my registered plugin function summarizeCategories, I take exactly two parameter as following:
function summarizeCategories(results, callback){
//do something with the results
callback(results);
}
Since I thought callback is the one I passed in!!
However, in hook.js, the callback function got wrapped around another callback function and the parameter that function takes are (err, values). Inside that the function, the original callback function was called, of course with with callback(err, results)
but not callback(results)
.
So in my registered function summarizeCategory I was passing in the result as err parameter and of course it gives me an err message. But then the falling call of original callback(err, results) still gives me the correct results information I needed in render. lol
That's was have happened. It's kind of complicated to trace the error down since so many things named similar but it was great fun and I really enjoyed how thing get beautifully wired up in NodeBB. Great job guys!
I wonder if there is any place that I can jot the point down so others may not fall in the same pitfall later? I saw your documentation is a bit out dated but you did mentioned it is going under a overhaul. I am looking forward to it.
@baris look at this:
19/3 09:53 [37042] - error: [plugins] filter:search.render, undefined
That's the information I have got with no other output. I tried to isolate which line trigger it, it seems to be the line in the dbsearch plugin callback(results), which content is
function(err ,v){
memo = v;
callback(err);
}
if there is no more wrapping's around the second callback, I guess it should trigger the callback function which was passed when the filter:search.render event is fired.
@baris That's great! I will go and pull the latest one.
By the way, I wonder what is the reason for it triggering filter:search.render, undefined error? I didn't see anywhere in the module check the registration for the hooks and I wonder what I have missed. Just very curious about that. Thanks!
By the way, your avatar looks soooooo cute, cannot staring at it
@baris Which version are you currently running? I am using v0.6.1, which I believe is the latest version?
As far as I see, there is only one hook related to search which is filter:search.query
. That hook run before the search is performed and is used by the dbsearch plugin. For my purpose, I want to perform some minor tweak to the results and render my own format, so if filter:search:build
do exist, I think that fits my purpose.
Thanks!
Hi NodeBB team,
I am working on a project that requires some aggregation of the search results like following picture shows. I currently added a little customized hook with the controller search.js, but I would really like to have an official hook from the general release because though it doesn't affect usage right now it gives me a error of filter:search.render undefined.
Following is my implementation and if you would like, I can also do a fork and pull request and implement the way according to your convention. Thanks!
if (!plugins.hasListeners('filter:search.render')) {
res.render('search', results);
}
else{
plugins.fireHook('filter:search.render', results, function(results){
res.render('search', results);
});
}
@pitaj I am not sure whether you intend to incorporate the functionality for adjusting the original navigation item or not. I made some change to your plugin and send you the pull-request
The basic idea behind the change is that I remove the original render logic from menu.tpl and all the navigation is actually rendering through the plugin right now. I remained the admin render logic since it request extra checking logic, which I am not sure how to get via plugin yet. So if the user activate the plugin, it won't render any navigation item before user set it up. In case user do want to revise from the default setting, I provided an extra button within the plugin page called "reset to default", so it will reset the navigation items to the original menu.tpl one.
See if you like it.
Hi all,
I wonder if anyone has previously used nodebb-plugin-custom-homepage before?
It is not working somehow and I looked into the implementing logic for it. It re-route the /
to a new rendering logic defined within the plugin called renderHomepage
and in that function it called res.render('homepage', {})
.
As far as I see, it does put the template file under public/template folder. However, {widgets.html}
seems not getting the corresponding value and somehow all the widget element was attached a class called 'hidden', which I guess is because it doesn't get the widget value?
For one more thing I would also willing to know is how does the single page application logic wired up? Because this plugin does override the initial HTTP request. However, if you click the logo later on, it still does the default action, which render the forum and ruin the purpose for the plugin.
I really appreciate if someone can help me with it.
PS: By the way, the original plugin does a little bug, so you need to change app.get('/', params.middleware.buildHeader, renderHomepage);
to app.route('/').get(params.middleware.buildHeader, renderHomepage);
. Because express will take the action as soon as it find out a matching route and stop further search for the following route. As we are trying to override the original action, I use route to get the original object and re-route it for the new action.
@pitaj said:
nodebb-plugin-header-extend
Hi pitaj,
Thanks for the wonderful plugin. I don't know whether it is possible for you to adjust the default header links as well through the plugin. I think it will be a good idea that so that I can remove the hacks from my custom CSS file.
May I know where I can get a general picture for the ACP overhaul? And I really appreciate if there is a timeline for the release.
I really like if the above feature for customize route will be included in the ACP overhaul. Then I guess we will be able to edit the route for each category through manage->categories, if I am getting it correctly?
Just cannot wait to see the next release and thanks for so many wonderful works you all have done so far. It is fantastic!