CheckboxTree Database Publishing

Has anyone writtten a DB Publishing template that will output a row entry per item selected in a checkbox tree with a column for content ID and a column for Checkbox reference. (i.e. one to many, the way the data is stored by Rhythmyx)

Not sure if I should be performing some iteration in a binding as I would in Velocity after using the getValues() function?

As a matter of fact, we had a requirement for something like this just last week.

What you have to do is use the foreach function in JEXL. Although the documentation won’t tell you this, the resulting binding $child[0].COLUMNNAME should be a LIST of values. You can create an empty list with

$valueList = $user.psoListTools.asList("x", 0);  

(The value x isn’t used, it’s a zero length list), and then add each value inside the foreach loop with:

$valueList.add($myValue); 

after the loop completes, just assign the list to $child[0].COLUMNNAME (or whatever the column name is).

I hope this helps

Dave

We’ve just assigned the column the value:

$child[0].CONTENTID = $sys.item.getProperty("rx:sys_contentid").String
$child[0].CHECKBOXTREE_VALUE = $sys.item.getProperty("rx:fieldname").getValues()

Cheers
James

Interesting solution however how does one replicate the child table as stored in Rhythmyx i.e. a selected value per row?

Hi Daniel

As the getValues() function returns a list you get a row for each value in the list eg

contentid = 1234
list = (1, 2, 3, 4)

child table rows:

1234, 1
1234, 2
1234, 3
1234, 4

Cheers
James