Saturday, July 7, 2012

In Liferay How can you add CSS or JS scripts to HEAD section?

Liferay Portal 5.2.3/6.x doesn’t support adding DOM elements to the head section, but it provides a much simpler alternative.

You can use the liferayportlet. xml file, as shown here:

<liferay-portlet-app>
<portlet>
<portlet-name>bookCatalog</portlet-name>
<instanceable>true</instanceable>
<header-portlet-css>/css/bookCatalog.css</header-portlet-css>
<header-portlet-javascript>/js/bookCatalog.js</header-portlet-javascript>
</portlet>
</liferay-portlet-app>


The liferay-portlet.xml file shown here makes use of <header-portlet-css> and <header-portlet-javascript> to add <link> and <script> tags to the generated markup;

No comments:

Post a Comment