cancel
Showing results for 
Search instead for 
Did you mean: 

How to include new libraries in Alfresco share?

upforsin
Star Collaborator
Star Collaborator

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 4

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

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>

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

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

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