Re: leftJoin (with images and multiple "joins" and multi-selects)

2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 3, 2023   (RSS)

By Dave - April 3, 2023

Hi Jeff, 

If you use any of the code generator functions (getRecords,etc) it should do it automatically.

But if you're using custom code and getting the data right from the database you can use one of our internal functions from /lib/upload_functions.php

// Returns the absolute uploadDir and uploadUrl for a specific upload field. This is determined by: The dir/url of the CMS,
// .. the (potentially relative) upload dir/url in settings, and the (potentially defined) custom upload dir/url for the field.
// Usage: list($uploadDir, $uploadUrl) = getUploadDirAndUrl($fieldSchema);
function getUploadDirAndUrl($fieldSchema, $settingsUploadDir = null, $settingsUploadUrl = null, $returnOnErrors = false) {

So you might have something like this:

<?php 
  $tablename   = "blog";
  $fieldname   = "uploads"; 
  $schema      = loadSchema($tablename);
  $fieldSchema = $schema[$fieldname];
  list($uploadDir, $uploadUrl) = getUploadDirAndUrl($fieldSchema);
?>

If you have that above your foreach block you can output the uploadUrl before each image.  And I think you'll need to output just the filename for the upload.  You may need to try a few variations of the code, but hopefully that will point you in the right direction.

Dave Edis - Senior Developer
interactivetools.com