showing specific records and linking to different templates

3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 23, 2013   (RSS)

By gregThomas - July 18, 2013

Hi  shawnpatoka,

I think the issue is that you don't have a clause in your trueAddressRecords where statement to retrieve gold and silver results, it's only retrieving results for platinum. You should find that the bar currently appears on page 19-21 of your falseAddressRecords list once platinum is deselected. I think you just need to add some extra lines to your trueAddressRecords statement to retrieve the gold and silver results as well, and make sure these don't appear in your falseAddressRecords:

  // get records
  $addressRecords = array();
  if ($myLat && $myLng) {
    $maxDist = floatval(@$_REQUEST['maxDistance']);
    list($trueAddressRecords, $trueAddressMetaData) = getRecords(array(
      'tableName'     => 'participating_bars',
      'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
      'where'         => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles),   // optimization: remove results outside of minimum bounding rectangle
      'having'        => "_distance <= " . $maxDist, // only show results within max distance
      'orderBy'       => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
      'where'         => "platinum  = '1' OR gold = '1' OR silver = '1'", 
    ));
  }

  
// get records
  $addressRecords = array();
  if ($myLat && $myLng) {
    $maxDist = floatval(@$_REQUEST['maxDistance']);
    list($falseAddressRecords, $falseAddressMetaData) = getRecords(array(
      'tableName'     => 'participating_bars',
      'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
      'where'         => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles),   // optimization: remove results outside of minimum bounding rectangle
      'having'        => "_distance <= " . $maxDist, // only show results within max distance
      'orderBy'       => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
      'where'         => "platinum  = '0' AND gold = '0' AND silver = '0'",   
      'perPage'       => '5',
    ));
  }

?>

So if you add the new where statements to your current code you should find that the true results now collect all of the platinum gold and silver results, and the false address records will return anything that doesn't have these three checkboxs selected.

Let me know if you have any questions.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By shawnpatoka - July 23, 2013

thank you very much Greg. I originally tried doing something like that, but did  not have "OR" in there. 

Thanks again!