« Back

Adding page-level JavaScript

To add page-level JavaScript (for example pointing to the JWPlayer) the file liferay-portlet.xml needs to be edited.

The script is referenced in a line of XML using <header-portlet-javascript> within a <portlet>:

<portlet>
     <portlet-name>2</portlet-name>
     <icon>/html/icons/my_account.png</icon>
     <struts-path>my_account</struts-path>
     <portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
      <control-panel-entry-category>my</control-panel-entry-category>
      <control-panel-entry-weight>1.0</control-panel-entry-weight>
     ....
     ....
     <header-portlet-javascript>/path/to/script</header-portlet-javascript>
    ....
    ....
</portlet>

Once the change is made (and the script is in the correct location on the server or remotely) the server should be restarted to pick up the change.

Similar settings can be applied for CSS, etc.

0 Attachments
9870 Views
Average (1 Vote)
The average rating is 5.0 stars out of 5.
Comments