How to include external script?
-
I thought only I did stuff like that
-
Within the config.json of your NodeBB installation you can set up a relative path to prepend all NodeBB URLs, so this would result in your files beeing accessed in
/relative/path/plugins/nodebb-plugin-teamspeak/public/datetimepicker/jquery.datetimepicker.min.js
I don't have a installation to make sure now but as far I remember this is the way it works... -
How would that help though? It seems like it's more complicated.
-
In which way should it be more complicated?
I've tested now. If you set
"relative_path": "/board"
you need to access /board/plugins/my-plugin/static/dir/path/file and the value ofRELATIVE_PATH
is"/board"
.So if the admin has set up correctly with the correct
base_url
anduse_port
,{relative_path}/plugins/nodebb-plugin-teamspeak/public/datetimepicker/jquery.datetimepicker.min.js
should give you the correct URL.EDIT: use the template-variable
{relative_path}
rather than js-tag -
But I could just access
plugins/my-plugin/static/dir/path/file
without the extra/board
and without configuring anything. What is the advantage of doing this? Freeing up url namespace? -
The advantage is that some admins don't want to have NodeBB at the root of their websites.
So they can do this by changing the config and NodeBB takes care of it.But if your plugin doesn't take care of this it'll be broken (at least the datetimepicker) for those installations.
-
Okay I understand.
-
Thanks for your help @frissdiegurke
-
haha @julian late to the party. As am I of course. Glad you guys figured it out
-
@julian I wasn't getting any errors when using the scripts property from the plugin.json. They simply weren't included on any of the admin pages.