I have a use case where I need to get a list of all the component links for a given component on the CD side. The reason for this is that I need to track all the pages that the component is on.
My thought was to use ComponentLink class, which normally returns either the first resolved Component Link or the best resolved Component Link via the standard Dynamic Linking Algorithm, and I was hoping that there would be method that return all the links (that the Dynamic Linking Algorithm does it's priority-based resolution on). This method seems to exist as per the Java doc:
com.tridion.linking.ComponentLink
protected java.util.List<LinkInfo> getLinkInfo(int publicationId, int componentId)
Loads the ComponentLinkInfo for a component in a publication. The collection returned contains a list of ComponentLinkInfo objects. Parameters:
- publicationId - The ID of the publication.
- componentId - The ID of the component.
Returns: A Collection of ComponentLinkInfo objects if they could be found. If an error occurs or the information isn't available, an empty collection will be returned.
As you can see the method exists, but it's protected
, not public
. So we can't use it unless our custom class is in the same package as the ComponentLink
class, i.e. com.tridion.linking
.
My question is, how do I get the list of urls for a given published Component(Presentation)?