Display select uploads from one category on another category page using pulldown (multi value) list

2 posts by 1 authors in: Forums > CMS Builder
Last Post: July 24, 2017   (RSS)

By Mikey - July 24, 2017

I got this working. The fix should have been obvious to me, but that how it goes sometimes.

Anyone who may need a solution similar to this... I changed ( '%\t$filterItem\t%' ) seen in black bold to read as seen in bold red ( '$filterItem' ).

// load record from 'solutions'
  list($solutionsRecords, $solutionsMetaData) = getRecords(array(
    'tableName'   => 'solutions',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $solutionsRecord = @$solutionsRecords[0]; // get first record
  if (!$solutionsRecord) { dieWith404("Record not found!"); } // show error message if no record found


 ///////////////// solutionsRecord /////////////////
   $searchString = '';
  //Create the where statement to be used to filter partners
  
  //if partners values have been selected....
  if(is_array(@$solutionsRecord['partners:values'])){
    //Count the total number if items in the array.....
    $arrayCounter = count($solutionsRecord['partners:values']);
    //Loop through the array....
    foreach($solutionsRecord['partners:values'] as $key => $filterItem){
      //create the search string that searches the "partner records" for the num value....
      //$searchString .= "num LIKE '%\t$filterItem\t%'";
      $searchString .= "num LIKE '$filterItem'";
      //If this is not the last item to filter by, add or to the statement....
      if(($key+1) != $arrayCounter){
        $searchString .= " OR ";
      }
    }  
  }
///////////////// partnersRecords /////////////////

  // load records from 'partners'
  list($partnersRecords, $partnersMetaData) = getRecords(array(
    'tableName'   => 'partners',
    'where'       => $searchString,
    'loadUploads' => true,
    'allowSearch' => false,
  ));

<?php foreach ($partnersRecords as $record): ?>
    <?php foreach ($record['partner_logo'] as $index => $upload): ?>
    <img src="<?php echo htmlencode($upload['thumbUrlPath4']) ?>" alt="<?php echo $record['name'] ?>" />
<?php endforeach ?>
<?php endforeach ?>

Zicky