掲示板

custom javascript doesn't work in Page Settings

16年前 に Ken Ko によって更新されました。

custom javascript doesn't work in Page Settings

Junior Member 投稿: 35 参加年月日: 07/09/23 最新の投稿
There is an area where it looks like you can type in custom javascript for Page Settings for a particular page.

Can someone confirm whether or not this works?

I know it saves into the Layout table in the DB, but it's not used anywhere
thumbnail
16年前 に Ray Auge によって更新されました。

Re: [Liferay Forums][2. Using Liferay]custom javascript doesn't work in Pag

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
> There is an area where it looks like you can type in custom javascript for Page Settings for a particular page.
>
> Can someone confirm whether or not this works?
>
> I know it saves into the Layout table in the DB, but it's not used anywhere

I can confirm it doesn't work... but making it work is simple...

I added the following code at ~line 446 of
portal-web/docroot/html/common/themes/top_head.jsp, right after
the
<%@ include file="/html/common/themes/top_js-ext.jsp" %>


Add:
<c:if test="<%= (layout != null) %>">
	&lt;%
	Properties typeSettingProperties = layout.getTypeSettingsProperties();
	%&gt;
	<script type="text/javascript">
		<%= typeSettingProperties.getProperty("javascript-1") %>

		<%= typeSettingProperties.getProperty("javascript-2") %>

		<%= typeSettingProperties.getProperty("javascript-3") %>
	</script>
</c:if>


I'm not exactly sure what the intention was for the three different js
fragemtents and if they were supposed to be loaded in specific areas or
the page... but you could make that decision in your theme by loading it
where you need it.

In VM you could use something like

$layout.getTypeSettingsProperties().getProperty("javascript-x")