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 Mikey - November 12, 2015

I like long descriptive titles on the forum - helps me find solutions faster, hence the long title.

On to the issue I have.

I have a "category" menu type (zoning_rezoning_status) which has a:
Name field
Upload field (for uploading an icon that represents the name of the category recored created. For example: if the category record name was "Dog" then I'd upload an icon of a dog.

Next I have a "multi" menu type (zoning_rezoning) which has a "list" field type called (status) set to "pulldown" with the options selected below:
Get options from database (advanced)
Section Tablename (set to) zoning_rezoning_status
Use this field for option values (set to) num
Use this field for option labels (set to) name

So I am creating records in the "multi" menu type (zoning_rezoning) and selecting from the pulldown called (status) to associate a "category" of the (zoning_rezoning_status) with the record of the "multi" menu type (zoning_rezoning).

I need to display the singular uploaded "icon" of the (zoning_rezoning_status) record associated with the record for the (zoning_rezoning) record on the "multi" List Page, but presently all icons of the (zoning_rezoning_status) are appearing for each "multi" list record on the List Page. Anyone have any suggestion on what I need to do to get this to work, so that the appropriate icon is displayed with the associated with the multi record created?

Here's my code:

<?php
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',
    'where'       => "name LIKE '%".$zoning_rezoningRecords['status:label']."%' ",
    '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']) ?>

<?php if ($record['status']): ?>
<div>
<h6><?php echo $record['status:label'] ?></h6>

<?php foreach ($zoning_rezoning_statusRecords as $statusicon): ?>
      <?php foreach ($statusicon['status_icon'] as $index => $uploadedicon): ?>
      <img src="<?php echo htmlencode($uploadedicon['thumbUrlPath2']) ?>" width="<?php echo $uploadedicon['thumbWidth2'] ?>" height="<?php echo $uploadedicon['thumbHeight2'] ?>" alt="<?php echo $record['status:label'] ?>" />
      <?php endforeach ?>
<?php endforeach; ?>
<div class="clear-both"></div>
</div>
<?php endif; ?>

<?php endforeach ?>
</body>
</html>

Thanks Zicky

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