ZenDB and images
3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 27 (RSS)
By kitsguru - November 6
I am correct that ZenDb does not return images as part of its record set and that we should use getRecords when we want images.
By Dave - November 8
Hi Jeff,
Using getRecords() might be the easiest right now, we're working on other options for ZenDB in future.
Or here's a workaround using a CMSB function that gets you an array:
$rows = DB::select('articles')->toArray();
addUploadsToRecords($rows, $baseTable);
showme($rows);
Or converting it back to a SmartArray and using that.
$rows = DB::select('articles')->toArray();
addUploadsToRecords($rows, $baseTable);
$rows = SmartArray::new($rows);
showme($rows);
foreach ($rows as $record) {
echo "<h1>$record->name</h1>\n";
foreach ($record->uploads as $upload) {
echo "<img src='$upload->urlPath'><br>\n";
}
}
Hope one of those solutions works for you.
Cheers!
interactivetools.com
By Dave - November 27
Hi Jeff,
We've now got this built into the latest CMSB beta. Here's what you can do in the beta instead of the above code:
$records = DB::select('articles');
foreach ($records as $record) {
echo "<h1>$record->name</h1>\n";
foreach ($record->load('uploads') as $upload) {
echo "<img src='$upload->urlPath'><br>\n";
}
}
If you get a chance to try it out let us know any feedback. Thanks!
interactivetools.com