掲示板

How to include JavaScript Library in a Liferay 6.2 GA4 Theme

thumbnail
8年前 に Omar Samir によって更新されました。

How to include JavaScript Library in a Liferay 6.2 GA4 Theme

Junior Member 投稿: 29 参加年月日: 15/05/19 最新の投稿
Hello Everyone

In my portlet I use 2 javascript libraries and I include them in liferay-portlet.xml and after generating my ( .war ) file and deploy it to my theme ,, the portlet uses the 2 javascript libraries at the first time and after refresh the page all the content of portlet disappears so the portlet not still uses the javascript libraries ,, I searched for this issue and I found that I must include my javascript files in liferay theme and declare them in file called "Portal_normal.vm" ,, the problem now
I can't get the path of where I should include my javascript libraries and the full path of the "portal_normal.vm" that I must declare the libraries in it ,,


I need help to find the desired paths for javascript libraries declaration !!

sorry for prolongation

thanks in advance ,, emoticon
thumbnail
8年前 に Miroslav Ligas によって更新されました。

RE: How to include JavaScript Library in a Liferay 6.2 GA4 Theme (回答)

Regular Member 投稿: 152 参加年月日: 14/07/29 最新の投稿
Hi

If you use portlet specific JS libraries that have no usage in other parts of the portal you should not include them in the theme. The declaration in liferay-portlet.xml is fine. Just make sure that you use the right tag - header-portlet-javascript.

If you have common JS libraries that are used all over the portal (e.g. jQuery...) then it might be desirable to place them in the theme. You need to create your new costume theme. and in the theme you can add the portal_normal.vm template. There in the header you use HTML script tag to include the common libraries. bear in mind that you creating a dependency between your theme and portlet application.
thumbnail
8年前 に Omar Samir によって更新されました。

RE: How to include JavaScript Library in a Liferay 6.2 GA4 Theme

Junior Member 投稿: 29 参加年月日: 15/05/19 最新の投稿
Miroslav Ligas:
Hi

If you use portlet specific JS libraries that have no usage in other parts of the portal you should not include them in the theme. The declaration in liferay-portlet.xml is fine. Just make sure that you use the right tag - header-portlet-javascript.

If you have common JS libraries that are used all over the portal (e.g. jQuery...) then it might be desirable to place them in the theme. You need to create your new costume theme. and in the theme you can add the portal_normal.vm template. There in the header you use HTML script tag to include the common libraries. bear in mind that you creating a dependency between your theme and portlet application.





Hello Miroslav ,,

Thanks alot ,, I found that I use a wrong tag <header-portal-javascript> instead of <header-portlet-javascript> and also I edited some default js tags uses <footer-portlet-javascript> to header one ,, thanks dear Very Good