07-25-2019 03:05 PM
Hello,
I am developing custom controls for alfresco share (by creating Freemarker templates) and I would like to include additional JavaScript libraries (i.e. Select2). How can I achieve that?
Normally i would put them in <head> tag, but in .ftl files it does not work.
Regards,
Mike
07-26-2019 04:04 AM
You need to add those files as dependency in share-config-custom.xml.
<config>
<forms>
<dependencies>
<css src="/res/scripts/DITAStorm/styles.css" />
<js src="/res/scripts/DITAStorm/DITAStorm.js" />
</dependencies>
</forms>
</config>
07-26-2019 04:58 AM
Thank you, but I am on Docker so do not have direct access to /res/scripts folder.
I also cannot provide absolute path because it is adding "http://localhost:8180/share/res/com/myproject/" all the time.
Of course I tried to add those files into the src/main/resources/alfresco/web-extension/site-webscripts/com/myproject or src/main/resources/res/scripts/ folder but it does not work 😕
07-28-2019 12:16 AM
You need to place js file inside src/main/amp/web/js of share folder.
07-29-2019 08:09 AM
Thank you for the answer. I managed to do it by modifying Dockerfile but your solution seems to be better.
Unfortunately, the script throws an error in the browser.
It looks like the library itself have an error somewhere (which is obviously a nonsense - it is working on my demo HTML page). Maybe it is connected with the fact that Alfresco has it's own, very limited, Javascript engine (Rhino)... or because this library needs jQuery which might be loading after this script
Explore our Alfresco products with the links below. Use labels to filter content by product module.