掲示板

how to show custom theme variables stored in the init_custom.vm in jsp

11年前 に Siju Thomas によって更新されました。

how to show custom theme variables stored in the init_custom.vm in jsp

New Member 投稿: 4 参加年月日: 11/07/27 最新の投稿
#set ($companyName = "shark")
#set ($companyUrl = "http://www.shark.com")
#set ($companyEmail = "info@shark.com")
this is my custom variables saved in init_custom.vm . How to show this vm variable values in my login.jsp in Hook.
I am using below code and its not working
Welcome to the <%=themeDisplay.companyName%>
thumbnail
11年前 に Olaf Kock によって更新されました。

RE: how to show custom theme variables stored in the init_custom.vm in jsp (回答)

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
You'll have to understand that init.vm (or init_custom.vm) just initializes what is available to velocity when interpreting the theme - it does not modify what is happening in the backend, e.g. it's not going back to what is available from the API (as is themeDisplay)

My advice would be to just set the companyName, URL and Mail through ControlPanel, Portal Section, "Portal Settings". In case you have definitive needs to customize them when your theme is active, you should go either through theme properties like this:
&lt;%=themeDisplay.getThemeSettings().getProperty("my-custom-information") %&gt;
or alternatively use the API to change the globally available company data (in case you want that).

You can even make them configurable if you add them to your theme:

	<theme id="classic" name="Classic">
		<root-path>/html/themes/classic</root-path>
		<templates-path>${root-path}/templates</templates-path>
		<images-path>${root-path}/images</images-path>
		<template-extension>vm</template-extension>
		<settings>
			<setting configurable="true" key="my-custom-information" value="Whatever default you'd like" />
		</settings>
	</theme>
11年前 に Siju Thomas によって更新されました。

RE: how to show custom theme variables stored in the init_custom.vm in jsp

New Member 投稿: 4 参加年月日: 11/07/27 最新の投稿
Thank you Olaf
thumbnail
9年前 に Arunjyoti Banik によって更新されました。

RE: how to show custom theme variables stored in the init_custom.vm in jsp

Junior Member 投稿: 74 参加年月日: 14/08/26 最新の投稿
Hii Olaf,

I want to write this below java code in init_custom.vm

List<Group> siteLst = GroupLocalServiceUtil.getUserSitesGroups(user.getUserId());
Group siteGrp = null;
for (Group site:siteLst)
{
if (site.getType()==2)
{
String url = siteGrp.getFriendlyURL();
}
}

I was trying for the siteLst only, like this::
#set($siteLst = $groupLocalServiceUtil.getUserSitesGroups($user.getUserId()));

But the page just shows $siteLst when i am placing it in portal_normal.vm. Obviously I am doing wrong and I guess it is not the correct way I am trying to define the 'siteLst' in init_custom.vm. Can you show how can I define it, mainly the siteLst and the for loop??