How can I get the content ID of a translation parent during database publishing?

I’m trying to figure out how to retrieve an item’s translation parent from within the bindings of a database publishing template. I have the latest PSO toolkit installed.

Failed Attempt 1: Used com.percussion.pso.jexl.PSORelationshipTools.findAllParentIds

I tried using this expression in my binding:


$user.psoRelationships.findAllParentIds($sys.item.getProperty("rx:sys_contentid").String,"")

I think the problem with this is that it needs a slot ID as the second parameter, and there is no slot ID for a translation parent, so I put in an empty string.

This error appears during assembly:
Problems during binding evaluation
$transparent=The slot specified by was not found

Failed Attempt 2: Used $user.psoNavTools.getAncestors

This code


$user.psoNavTools.getAncestors($sys.item) 

returned the object itself, rather than its translation parent.

Successful, but potential flawed Attempt 3: Used SQL query to retrieve translation parent content ID from PSX_OBJECTRELATIONSHIP table
I used these bindings, and was able to get the translation parent content ID, but it seems like there should be a way to use the API, rather than retrieving directly from the PSX_OBJECTRELATIONSHIP table. I’m concerned that I’m missing something in my understanding of the backend tables.


$sqlquery = "SELECT owner_id from psx_objectrelationship where dependent_id=" + $sys.item.getProperty("rx:sys_contentid").String + " and config_id=6"
$transparentfromquery = $rx.db.get("RhythmyxData",$sqlquery)
$transparentcontentid = $transparentfromquery.get(0).get("owner_id")

Has anyone tried to do this? Does anyone have any suggestions for me?

Thanks,
Kathleen

Kathleen,

Neither of your first two attempts were intended for this functionality. PSORelationshipTools.findAllParentIds is limited to Active Assembly relationships, and PSONavTools.getAncestors is limited to the navigation slots.

You’re correct that you should use the API for this. I’m pretty sure that we do not yet have a JEXL function that fulfills this need, although this doesn’t sound like a particularly difficult one to implement.

What is the ultimate goal here? Do you need to extract data (fields and/or assembled templates) from the translation parent? Publish a URL to the translation parent? Or do you just need the id to store in the database?

The most generic way to do this might be to create a slot finder for translation parents: this would allow you to link to a translation parent with a simple slot. Of course, for database publishing you’d have to use the getSlotContents() function: it would require more work than a JEXL function that was optimized for Database Publishing.

There’s no way that we can implement (or even think of) all of the possible functions of this type. Our original hope was that you (and other customers) would be able to take the API and build new JEXL functions for problems like this one. I’m more than willing to provide guidance (and even to implement simple functions where I can do them quickly).

Dave