I have an issue with getting the Values of my Custom Attributes (Site) in the Liferay Staging-Mode.
I'm trying to get the Values with following Code in my Theme:
Map<String, Serializable> myAttributes = site.getExpandoBridge().getAttributes();
But the output on staging is empty:
{custom-attribute-1=, custom-attribute-2=}
Output on Live:
{custom-attribute-1="mystring", custom-attribute-2="mystring"}
I'm using Liferay 6.2+
Do you have any ideas? Thank You!
your problem seems to be a "Liferay feature". If you use Site Custom Attributes or better known as Group Expando Values, each Group Expando Values points to the classPk of its Site. For example my Expando Value data_ is "21005" and the classPK (Group/Site Id) is "20373".
You can check this in your Liferay Database:
SELECT * FROM lportal.expandovalue where data_ like 21005;
The classPk "20373" you will get is the classPk of your Life-Site and NOT the classPk of your Staging-Site.
That´s because Liferay generates a new Group for your Staging Site with a new classPK (for example: "20791") and an extra database entry: lifeGroupId = "20373".
You can check it in your DB:
SELECT * FROM lportal.group_ where liveGroupId like 20373;
Then you will get your Staging Site.
Sorry for the difficult explanation, but it is a difficult issue you got.
And what is the solution?
In your Theme (or somewhere you get the Expando Values) you have to check if it is a StagingGroup and use the expando values of LiveSite. Something like that:
if (myGroup.isStagingGroup(){ //com.liferay.portal.model.Group
myLiveGroup = myGroup.getLiveGroup;
Map<String, Serializable> myAttributes = myLiveGroup.getExpandoBridge().getAttributes(); //Use the expando values of Livesite
}
I hope my answer can help you to display your expando values on your Staging Site.