add javascript code
-
@DennisSun If you manage, tell me how you did it
-
@Giorgio-Chiodi Well, I am pretty a beginner.. I did see a footer.tpl in the Vanilla folder... So I feel strange that there isn't in the lavender... Sorry I typed the "lavender" as vanilla there.
-
@DennisSun The reason there's no footer.tpl in Lavender is because it uses the footer.tpl inside Vanilla. The only reason you'd create new files in new templates is if you wish to change the functionality of Vanilla. Hence Lavender.
It's a sort of hierarchy system, Magento uses it, Simple Machines uses it. You will have your "core" theme. Which is the default. In this case Vanilla, if no footer.tpl is defined in Lavender, it will be pulled from the core theme instead. If you wish to overwrite it, then just go into the Lavender templates folder, nano footer.tpl, copy the code from the vanilla footer.tpl into the lavender footer.tpl, and add your changes.
Making changes to core is never a good idea, as you've made potentially breaking changes to your one and only fallback.
Hope that more explains the process.
-
@DennisSun said:
The widget doesn't works all the time.
really?
if it's static JS that you do not need to change it, create a quick custom-plugin, with this structure and use the 'scripts' in plugin.json
-
ah,
they usually support a jsonp callback param along with of
document.write
,
i.e. http://example.com/api/boom?callback=yourGlobalFunctionNameworth checking their docs
-
@planner said:
This really does bring up the reason NodeBB should have an easy method of adding script tags to the system either via a global footer or header widget in the ACP that is not held hostage by AJAX.
Once I get #1428 fixed, this won't be a problem
-
@psychobunny said:
Once I get #1428 fixed, this won't be a problem
Nice, care to put an ETA on that?
-
Just the nature of the
document.write
method. It was created probably more than 14 years ago, at this point, so back then nobody (except possibly a couple very forward thinking people) expected that javascript would be used in this manner.It probably just made complete sense that after a page had "finished" loading,
document.write()
would rewrite the page from scratch again. -
@DennisSun have a look here for a way to overload the
document.write
method and make it play nice with dynamically loaded pages