We are publishing a content type out to a database. This content type contains a slot that can contain files (e.g. PDFs). I am trying to publish the title and url for said PDFs in a child data base. The issue is that I can only publish a single PDF url to all the child rows because I cannot progress through the list of content in the slot with an iterator for each new row in the child table.
What I need is a way to replace the 0 in the third binding with a variable that iterates with each new row to the CMS_ACCESSORY_LINKS table (or which is based on the current item index in $slotcontent).
When you are mapping to a child column in the destination database it is expecting to be provided a List of the values e.g. holding the value for each child row. e.g. for a multi valued field you can use $sys.item.getProperty(“fieldname”).getValues() which returns a list. If you just want a particular child field you can extract this list using $rx.asmhelper.childValues(parentNode,childName,propertyName). as you are using a function on the node itself you would have to use a loop and populate a list. Creating an empty list is not so straightforward in this version of jexl, you can use the $user.psoListTools.asList(null); The parameter here is a single object you want to wrap in a list, if you pass null it will be an empty list. In jexl you can have multiple lines, the last statement that returns a value is what is set to the variable on the left side of the binding. I have not tested this but something like the following may return a list of locations as required.
Just a warning though, this does not work for snippets in the slot containing external links etc, as you cannot use $rx.location.generate unless there is a real location scheme for the item. Another way to get around this is by using a standard binding on your templates e.g. $pagelink. You can access the bindings on the assembled snippet like this $slotitem.getBindings().get(’$pagelink’) (may need to escape the $). The actual template can then use whatever mechanism it likes to generate the link.
produces error: $test=Problem parsing expression: $links = $user.psoListTools.asList(null); for($slotitem:$slotcontent){ $links.add($rx.location.generate($slotitem,‘cltPgTopic’,null)); } $links; at character 44
left side: $test2; right side:
$y=0; for($x=0;$x>10;$x++){ $y = $y + 1; } $y;
produces error: $test2=Problem parsing expression: $y=0; for($x=0;$x>10;$x++){ $y = $y + 1; } $y; at character 7
I have looked at the documentation for java’s for loop, and it would appear that both “signatures” are acceptable, one being a traditional for loop, the other being more like a foreach, but neither seems to work as a binding in my database template.