How to include new libraries in Alfresco share?

cancel
Showing results for 
Search instead for 
Did you mean: 
upforsin
Senior Member

How to include new libraries in Alfresco share?

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

howkymike
Alfresco Developer
4 Replies
sanjaybandhniya
Intermediate

Re: How to include new libraries in Alfresco share?

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>
upforsin
Senior Member

Re: How to include new libraries in Alfresco share?

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 :/

howkymike
Alfresco Developer
sanjaybandhniya
Intermediate

Re: How to include new libraries in Alfresco share?

You need to place js file inside src/main/amp/web/js of share folder.

upforsin
Senior Member

Re: How to include new libraries in Alfresco share?

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

howkymike
Alfresco Developer