Is it possible to publish images from a child table using 6.5-style search generated content lists and binary templates?
I have a set of content types left over from my 5.7 implementation that I’m trying to update to the 6.5 way of doing things. We have images stored in BLOBs in child tables (I know, this is not ideal, but its what i was given to work with).
I need to build a content list that will list each child table entry and a templace that will publish them.
Does anyone have an example of this… or any advice?
I had indended to start with the template and work backward. I was able to get the mime type with a JEXL expression like this:
$t = $sys.params.get(“sys_sortrank”); $n = $rx.string.extractNumber($t[0]).intValue(); $i = $tools.math.sub($n,1);
$rx.asmhelper.childValues($sys.item, “ads”, “rx:img_type” ).get($i).string
What this does is load the sortrank from the query string, parse the query string’s value into an integer, get the child index by subtracting 1, and attempt to get the mime type of that numbered child.
But the same doesn’t work for the binary data itself. I tried this:
$t = $sys.params.get(“sys_sortrank”); $n = $rx.string.extractNumber($t[0]).intValue(); $i = $tools.math.sub($n,1);
$rx.asmhelper.childValues($sys.item, “ads”, “rx:img” ).get($i).string.getBytes()
Turns out that the image data gets corrupted using this method. I delved into the java classes and it seems that PSInputStreamValue is the issue here… It uses a string buffer to read binary data, and as such, i’d assume that if a null byte exists in the data stream, then it’ll terminate the string and hence the data for the image would be incomplete.
So… if I want to continue with this method, I’d need to do something like:
$stream = $rx.asmhelper.childValues($sys.item, “ads”, “rx:img” ).get($i).getStream();
and then try to load the data manually… but I can’t figure out how to create a new instance of a byte array… or any class, for that matter.
Any suggestions or alternatives?
Thanks in advance.