Forums de discussion

How to get instance-id attribute value of a dynamic element?

thumbnail
Abhishek Jain, modifié il y a 6 années.

How to get instance-id attribute value of a dynamic element?

Regular Member Publications: 226 Date d'inscription: 20/08/16 Publications récentes
I have a dynamic element named "location" . I want to ask how to get instance-id attribute value of that element in the template. I have tried method like ${location.attributeValue('instance-id')},${location.getAttributeValue('instance-id')},${location.getInstanceId()} but nothing worked.. So please help me ...
thumbnail
Olaf Kock, modifié il y a 6 années.

RE: How to get instance-id attribute value of a dynamic element?

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
What information do you expect in an instance-id of a location? I'm not aware that custom fields of a structure have an instance-id.
thumbnail
Abhishek Jain, modifié il y a 6 années.

RE: How to get instance-id attribute value of a dynamic element?

Regular Member Publications: 226 Date d'inscription: 20/08/16 Publications récentes
Actually I see the instance-id attribute of a dynamic element of a web content into the database and analyzed that this could be the only option to distinguish between two or more elements with the same name.. that's why I need its value..any sort of help would be appreciated.
thumbnail
Olaf Kock, modifié il y a 6 années.

RE: How to get instance-id attribute value of a dynamic element?

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
Some disambiguation:

There's a "portal instance", or "companyId" in technical terms. I'm assuming that you don't refer to this.

There's a portlet instance, e.g. any portlet that can be added to the page multiple times typically has one. I'm assuming you're referring to this.

An article (web content) doesn't have an instance-Id, as it can be displayed in any number of portlets, all with different instance-Ids, even at the same time, and even in portlets that don't have an instance-Id, because they may be added to the page only once. You could also render a web content article in the context of sending a mail (not out of the box, but it's possible).

You may or may not find a context object for the current portlet (check if you can find themeDisplay somewhere, and if it has matching data), but you still must take care that there could be no instance-Id. However, if you find the context, you might find the portlet's id - provided the article is rendered in a portlet. Searching for this data within the article or even within a single element of the article is the wrong place.

Unless there's a third meaning of "instance" that I'm currently not aware of.