Where to check for matches and filter out

3 posts by 3 authors in: Forums > CMS Builder
Last Post: January 17, 2020   (RSS)

By Zicky - January 17, 2020

On my Geo Map, I need to filter out homes that are not related to a floor plan, so that only home floor plans that match the floor plan's record number are displayed.  I am trying to create this 'where' => 'floor_plan' == $floor_plansRecord['num'], to accomplish the job, but it doesn't seem to work. Any suggestions on the right configuration for this to accomplish the filtering?

  // load record from 'floor_plans'
  list($floor_plansRecords, $floor_plansMetaData) = getRecords(array(
    'tableName'   => 'floor_plans',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $floor_plansRecord = @$floor_plansRecords[0]; // get first record
  if (!$floor_plansRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
    // load records from 'homes_for_sale'
  list($homes_for_saleRecords, $homes_for_saleMetaData) = getRecords(array(
    'tableName'   => 'homes_for_sale',
    'loadUploads' => true,
    'allowSearch' => false,
    'orderBy' => 'price ASC'
  ));

  list($myRecords, $myMetaData) = getRecords(array(
    'tableName'   => 'homes_for_sale',
    'where'       => 'floor_plan' == $floor_plansRecord['num'],
    'allowSearch' => false,
  ));

Thanks, Zicky

By gkornbluth - January 17, 2020

Hi Zicky.

Take a look at this recipe in my CMSB Cookbook.

It might help.

CREATING-A-LIST-PAGE-WITH-NESTED-INFORMATION-FROM-2-MULTI-RECORD-EDITORS

http://www.thecmsbcookbook.com/recipedetail.php?83

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php