plugin load sequence
-
Instead of replacing the template like you are doing, make your changes to the file at runtime, using the emitter event 'nodebb:ready' like here.
Rename your template to sort-by-votes.tpl so that the original isn't replaced, and only put your changes inside. When the ready event happens, modify the original template by adding your changes to it with a replace(). Like shown here.
-
Here's a regex you can use for my method above.
Edit fiddle - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
(jsfiddle.net)
-
@pichalite said in plugin load sequence:
@xidui yes, you can order the plugins. On ACP -> Extend -> Plugins page there is a "Order Active Plugins"
That doesnt solve anything most of cases
-
@pichalite said in plugin load sequence:
@exodo explain?
If a plugin is slow it wont solve to put it first. It will still finish last. Happened to me with many plugins
-
I was wondering about that, the plugins load asynchronously it seems, so what does the order even do?
-
based on this... looks like they are loaded in order one after the other...
File not found 路 NodeBB/NodeBB
Node.js based forum software built for the modern web - File not found 路 NodeBB/NodeBB
GitHub (github.com)
-
@pichalite That makes sense, but the app.load hook is still called asynchronous. (each instead of eachSeries)
NodeBB/src/plugins/hooks.js at master 路 NodeBB/NodeBB
Node.js based forum software built for the modern web - NodeBB/src/plugins/hooks.js at master 路 NodeBB/NodeBB
GitHub (github.com)
So there is no way to tell if another plugin has finished loading yet.
-
This topic is deceiving though. The plugin load order has nothing to do with the issue. Like I said in my first post,
Plugins should not be replacing default templates, period.
It is ugly, not guaranteed to work, and breaks every other plugin that attempts to do the same.
I already suggested a more sensible system here.
Template placeholders. 路 Issue #4728 路 NodeBB/NodeBB
A few plugins modify templates at load or require manually editing templates. This works most of time, but is dependent on the theme and prone to breakage. If we could add template placeholders to themes that were filled in by NodeBB, it...
GitHub (github.com)
-
@pichalite That seems to me to be the case.
-
@yariplus said in plugin load sequence:
@pichalite That seems to me to be the case.
However, the code does not agree -- they are run in series.
They do time out for performance reasons, however. e.g. a static hook will continue with the next listener if the current one takes longer than 2 seconds.
-
@julian said in plugin load sequence:
@yariplus said in plugin load sequence:
@pichalite That seems to me to be the case.
However, the code does not agree -- they are run in series.
They do time out for performance reasons, however. e.g. a static hook will continue with the next listener if the current one takes longer than 2 seconds.
That reference is for
filter
hooks, isn't it? @yariplus and @pichalite are talking aboutstatic
hooks (e.g.static:app.load
). For static hooks @yariplus already referenced the relevant line to prove his point.
With that in mind I don't see any obvious solution/hook for that purpose, nor any reasonable use-case. -
Aah yes... static hooks are called asynchronously for performance reasons. Thanks for pointing that out @frissdiegurke, my apologies for missing your link in the earlier post @yariplus
We could change it to
eachSeries
... not that big a deal, to be honest. -
I'm fine with it being
each
. But that's really a separate issue. The app.load hook is not where we should be modifying templates.