Liferay - 自定义属性在暂存时为空
Liferay - Custom attributes are empty on staging
我在 Liferay 暂存模式中获取自定义属性(站点)的值时遇到问题。
我试图在我的主题中使用以下代码获取值:
Map<String, Serializable> myAttributes = site.getExpandoBridge().getAttributes();
但是暂存的输出是空的:
{custom-attribute-1=, custom-attribute-2=}
实时输出:
{custom-attribute-1="mystring", custom-attribute-2="mystring"}
我正在使用 Liferay 6.2+
你有什么想法吗?谢谢!
您的问题似乎是 "Liferay feature"。如果您使用站点自定义属性或更广为人知的 Group Expando Values,则每个 Group Expando Values 都指向其站点的 classPk。例如,我的 Expando Value data_ 是 "21005",classPK (Group/Site Id) 是 "20373".
您可以在您的 Liferay 数据库中查看:
SELECT * FROM lportal.expandovalue where data_ like 21005;
您将获得的 classPk "20373" 是您 Life-Site 的 classPk 而 NOT 您的暂存站点的 classPk。
那是因为 Liferay 使用新的 classPK 为您的暂存站点生成了一个新组(例如:"20791")和一个额外的数据库条目:lifeGroupId = "20373".
您可以在您的数据库中查看:
SELECT * FROM lportal.group_ where liveGroupId like 20373;
然后您将获得临时站点。
很抱歉解释困难,但你遇到的问题很棘手。
解决方法是什么?
在您的主题(或您获得 Expando 值的地方)中,您必须检查它是否是一个 StagingGroup 并使用 LiveSite 的 expando 值。类似的东西:
if (myGroup.isStagingGroup(){ //com.liferay.portal.model.Group
myLiveGroup = myGroup.getLiveGroup;
Map<String, Serializable> myAttributes = myLiveGroup.getExpandoBridge().getAttributes(); //Use the expando values of Livesite
}
希望我的回答可以帮助您在暂存站点上显示您的 expando 值。
我在 Liferay 暂存模式中获取自定义属性(站点)的值时遇到问题。
我试图在我的主题中使用以下代码获取值:
Map<String, Serializable> myAttributes = site.getExpandoBridge().getAttributes();
但是暂存的输出是空的:
{custom-attribute-1=, custom-attribute-2=}
实时输出:
{custom-attribute-1="mystring", custom-attribute-2="mystring"}
我正在使用 Liferay 6.2+
你有什么想法吗?谢谢!
您的问题似乎是 "Liferay feature"。如果您使用站点自定义属性或更广为人知的 Group Expando Values,则每个 Group Expando Values 都指向其站点的 classPk。例如,我的 Expando Value data_ 是 "21005",classPK (Group/Site Id) 是 "20373".
您可以在您的 Liferay 数据库中查看:
SELECT * FROM lportal.expandovalue where data_ like 21005;
您将获得的 classPk "20373" 是您 Life-Site 的 classPk 而 NOT 您的暂存站点的 classPk。
那是因为 Liferay 使用新的 classPK 为您的暂存站点生成了一个新组(例如:"20791")和一个额外的数据库条目:lifeGroupId = "20373".
您可以在您的数据库中查看:
SELECT * FROM lportal.group_ where liveGroupId like 20373;
然后您将获得临时站点。
很抱歉解释困难,但你遇到的问题很棘手。
解决方法是什么?
在您的主题(或您获得 Expando 值的地方)中,您必须检查它是否是一个 StagingGroup 并使用 LiveSite 的 expando 值。类似的东西:
if (myGroup.isStagingGroup(){ //com.liferay.portal.model.Group
myLiveGroup = myGroup.getLiveGroup;
Map<String, Serializable> myAttributes = myLiveGroup.getExpandoBridge().getAttributes(); //Use the expando values of Livesite
}
希望我的回答可以帮助您在暂存站点上显示您的 expando 值。