Show multiple Venues that are recommended for a type of Catering Event. Filter, Where, If Match

2 posts by 1 authors in: Forums > CMS Builder
Last Post: May 1, 2020   (RSS)

By Mikey - May 1, 2020

I need to show multiple Venues that are recommended for a type of Catering Event.

For example: There are 4 venues that are recommended for corporate catering events, and 12 venues recommended for wedding catering events.

I need to only show the 4 venues assigned to the corporate catering events, and only show the 12 venues for the wedding catering.

In the CMS:

I have a section editor called Venues where I add my venues, and another section editor called Events Catering where I add my event catering types.

In the Events Catering section, I have a pillbox where I can select the "num / title" of the Venues - which I wish to associate with the catering event record I am creating within the Events Catering section.

Below is the code I have been working with, but I can't seem to figure this out though - to get the page to show only the Venues that I have assigned to the Catering Event.

// load records
list($venuesRecommendedRecords, $venuesRecommendedMetaData) = getRecords(array(
	'tableName' => 'venues',
	'where'       => " num LIKE '%\t".$events_cateringRecord['recommended_venues']."\t%'",
));

Any suggestions would be greatly appreciated! 

Zicky

By Mikey - May 1, 2020

I got this figured out with help from a post by Greg.

https://www.interactivetools.com/forum/forum-posts.php?postNum=2243600#post2243600

Here's what I ended up with:

 //Convert the 'you might also like' num values into an array.
  $youMightLikeNums = explode("\t", trim($events_cateringRecord['recommended_venues'],"\t"));

  //If the product has linked you might also like products..
  if ($youMightLikeNums) {
    //Escape the values into a comma seperated string.
    $youMightLikeNums = mysql_escapeCSV($youMightLikeNums);
    
    //Pull the records with linked nums.
    list($venueRecommendedRecords, $venueRecommendedMetaData) = getRecords(array(
      'tableName'   => 'venues',
      'loadUploads' => true,
      'where'       => "`num` IN($youMightLikeNums)",
      'allowSearch' => false,
      //'debugSql'    => true,      // optional, display SQL query, defaults to no
    ));

Thanks Greg!!!

Zicky