I am using the PSO toolkit to retrieve a parent item within a Velocity template for database publishing. Currently, my code looks like this:
$parent_ids is a variable with binding:
$user.psoRelationships.findAllParentIds($sys.item.getProperty("rx:sys_contentid").String,"mwSeminarInstances")
One strange behavior that I’ve found is that this is returning a list that includes the content ID for a parent for which I have already removed the relationship. The parent’s last public revision DID have the relationship, but I have edited the parent, removed the relationship, and checked in the item (but NOT republished, so there is not yet a new public revision without the relationship).
Is there any way I can get only the parents who are related for their current revisions? I’ve written some convoluted code in Velocity that MIGHT work, but I wondered if there’s a more straight-forward way to do this.
“findAllParents” goes out of its way to find both parents of the current revision and parents of the last public revision.
At the service level IPSOParentFinder defines both a “findAllParents” and a “findParents” but it doesn’t look like we exposed this to JEXL.
You can either write a JEXL function that calls IPSOParentFinder.findParents and set the usePublic flag to “false” or I can expose this function for you (which means a new build of the PSOToolkit).
I have to check what other development is going on in the toolkit before I can tell you how long that will take, but this is a pretty simple change for us to make.
Another possibility is to use the PSOReverseSlotContentFinder. This already has a “public” parameter, and if you leave it blank, you will get only parents of the current revision.
Obviously, this only finds items where the relationship is in a specific slot rather than ALL relationships, so it may or may not work for you, depending on the specific reason you are looking for the parent item.
I will take a look at PSOReverseSlotContentFinder. I am looking for the parent for a particular slot, so that’s not a problem in this case.
If it’s simple to expose the findParents function, that would be good too - I would always welcome more options for JEXL functions. When I end up with a complex data model for my related content, I have to write more complicated code for file and database publishing, and the more functions in the library, the better.
If you’re after a single slot, the reverse slot content finder is simpler to use: just add it to the slot definition and then use getSlotContents() to retrieve the items in the slot.
I’ve added the new function to the PSOToolkit: there is another pending change for a customer reported bug that will come out in a day or two. This next toolkit will also support the findParent() function.