I am sorry for this very basic question I am asking as I could not fully understand the javadoc for this method.
The signature for this method is a list of Guids that need to be arranged. If I supply a list of guids of content items that are already in the same slot, would this method sort them as the method javadoc implies.
If so, is the sort going to be alphabetically and if so which field is used for this sorting. Is the sort field the sys_title field or something else?
The list of IPSGuid (parameter of reorderContentRelationss) is not a list of item GUIDs, but it is a list of PSAaRelationship GUIDs.
IPSContentWs.reorderContentRelationshs is similar with IPSContentWs.reArrangeContentRelations. Both sort the relationship by the “sortRank” property of the relationship object.
Both IPSContentWs.reorderContentRelationshs and IPSContentWs.reArrangeContentRelations will reset the sort-rank according to the order of the relationships you specified to the API.
That means you need to “sort” the relationships the way you wanted first, then pass to the API, which will rearrange the relationships according to your sorted result.
For example, if you retrieve all the relationships of a slot, rearrange the relationships according to the sys_title (or any other property of the dependent items), pass them to one of the API, then the items should be displayed in the slot according to your sorted order.
Yes…I was able to retrieve the list of Relations. After I look into an individual relation, I am not able to find any property by which I can load the content item that was added to the slot. I did a getAllProperties and got the following result.
To read the contents of the dependent item, you have to load the content node with the content manager.
The PSRelationship object is a legacy object (designed before there were GUIDs and Services).
PSRelationship.getDependent() will return a PSLocator. You can use the IPSGuidManager.makeGuid() method to create a GUID from the locator. The next step is to load the node with IPSContentMgr.findItemsByGUID() which requires a list of GUIDs. The “config” parameter can be left as null.
I think I have resolved the sort issue, and am able to sort the content items. Essentially, what I did was first I invoked the loadSlotRelations method. Then I manually sorted all the relations. After that I simply invoked the PSOSlotRelations.saveSlotRelations() method, and passed in the sorted list of Relations.
That approach obviously works, but as Ben pointed out earlier, you could also have used the “reArrangeContentRelations” method instead the “saveContentRelations” method. Using “reOrderContentRelations” requires you to build a list of Relationship GUIDs, rather than a list of Relationships.