【发布时间】:2014-09-24 23:00:35
【问题描述】:
我该怎么做
- 在我开发的自定义主题中添加带有自定义值的选择下拉菜单?
- 还需要设置该选择下拉菜单的默认值。
- 根据此选择下拉值更改主题中的一些内容。
我正在寻找实现上述内容的代码示例。
【问题讨论】:
我该怎么做
我正在寻找实现上述内容的代码示例。
【问题讨论】:
回答第一个和第二个问题:
- 在我开发的自定义主题中添加带有自定义值的 Select Dropdown?
- 还需要设置该选择下拉菜单的默认值。
在liferay-look-and-feel.xml 中,使用您的键添加选择主题设置
<look-and-feel>
<compatibility>
<version>6.2.0+</version>
</compatibility>
<theme id="theme-id" name="theme-id" >
<settings>
<setting type="select" configurable="true"
key="dropdown-title-key"
options="select-option-1,select-option-2"
value="select-option-2" ></setting>
</settings>
</theme>
</look-and-feel>
这些键应该在Language_en_US.properties 中有相应的文本值。这个属性应该通过一个钩子注入。
编写一个hook项目,在liferay-hook.xml中指定如下内容。
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<portal-properties>portal.properties</portal-properties>
<language-properties>
content/Language_en_US.properties
</language-properties>
</hook>
在content 文件夹(应位于类路径中)中,输入在Language_en_US.properties 文件中的liferay 主题设置中指定的键的文本。
dropdown-title-key=Choose a value from the dropdown
select-option-1=This is Option 1
select-option-2=This is Option 2
回答第三个问题:
- 根据此选择下拉值更改主题中的一些内容。
更改通常在完成选择下拉主题设置的主题的portal_normal.vm 文件中完成。
#if($theme.getSetting("dropdown-title-key")=='select-option-1')
##Do Something Here
#elseif($theme.getSetting("dropdown-title-key")=='select-option-2')
##Do Something Else Here
#end
【讨论】: