Display images from a "category" menu type, used as a list pulldown in a "multi" menu type and displayed on a list page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 16, 2015   (RSS)

By Daryl - November 16, 2015

Hi Zicky,

On your foreach block for $zoning_rezoning_statusRecords, you can skip displaying the icon if $zoning_rezoningRecord's 'status' ($record['status']) is not equal to $zoning_rezoning_statusRecord's 'num' ($statusicon['num']) until it found a match. 
For example:

foreach ($zoning_rezoningRecords as $record){
   foreach ($zoning_rezoning_statusRecords as $statusicon){
      if ($record['status'] != $statusicon['num']) { continue; } // skip

      // insert code for displaying the icon here

      break;
   }
}

Hope that helps!

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com

By Mikey - November 16, 2015 - edited: November 16, 2015

Hey Daryl,

Thanks for the assistance... I got it working from your guidance and the solution provided here: http://www.interactivetools.com/forum/forum-posts.php?postNum=2237431#post2237431:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  

  // load viewer library
  $libraryPath = 'cmsb/lib/viewer_functions.php';
  $dirsToCheck = array('/home/content/abc/efghj/html/domain/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
  if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); }
  
  
if (@$_REQUEST['searchResultsPerPage'] AND is_numeric(@$_REQUEST['searchResultsPerPage'])){
  $perPage = $_REQUEST['searchResultsPerPage'];
}
else{
  $perPage = '6';
}
  
    // load records from 'zoning_rezoning'
  list($zoning_rezoningRecords, $zoning_rezoningMetaData) = getRecords(array(
    'tableName'   => 'zoning_rezoning',
'perPage'     => @$perPage ? $perPage : '6',
'loadUploads' => true,
'allowSearch' => true,
    'orderBy'     => 'date DESC',
  ));
  
    // load records from 'zoning_rezoning_status'
  list($zoning_rezoning_statusRecords, $zoning_rezoning_statusMetaData) = getRecords(array(
    'tableName'   => 'zoning_rezoning_status',
    'loadUploads' => true,
    'allowSearch' => false,
  ));


?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Zoning Multi</title>
</head>

<body>
<?php foreach ($zoning_rezoningRecords as $record): ?>
<?php echo htmlencode($record['title']) ?>
<?php echo htmlencode($record['summary']) ?>


<h2><?php echo $record['status:label'] ?></h2>

<hr/>
Something should appear below<br>
<div>

<?php foreach ($zoning_rezoning_statusRecords as $statusicon): ?>
<?php if ($record['status'] != $statusicon['num']) { continue; } // continue looping if statusicon is not selected ?>
<?php foreach ($statusicon['status_icon'] as $index => $upload): ?>
<?php if ($index >= 1) { continue; } // limit uploads shown ?>
<div>
<img src="<?php echo htmlencode($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" />
</div>
<?php endforeach ?>
<?php break; ?>
<?php endforeach ?>
</body>
</html>

Thanks Zick