<?php include ("_top.php") ?>
<?php

  // load record from 'items'
  list($itemsRecords, $itemsMetaData) = getRecords(array(
    'tableName'   => 'items',
    'where'       => whereRecordNumberInUrl(0),
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $itemsRecord = @$itemsRecords[0]; // get first record

  echo '<h3>where clause</h3>'; 
  showme(mysql_escapef('products = ?', $itemsRecord['num'])); 
  
  list($downloadsRecords, ) = getRecords(array( 
    'tableName'     => 'downloads', 
    'where'         => mysql_escapef('products = ?', $itemsRecord['num']),
    'allowSearch' => false,
    'debugSql' => true,
  )); 
  $downloadsRecord = @$downloadsRecords[0]; // get first record
  
?>
  			<div id="breadcrumb">
			Products > <?php echo join(', ', $itemsRecord['product_group:labels']); ?>  > <?php echo htmlencode($itemsRecord['title']) ?>
			</div>
		<section class="body clearfix">
			<div class="eight columns alpha">
				<!-- ALL CONTENT GOES WITHIN THIS DIV-->
				<?php echo $itemsRecord['content']; ?>
				<!-- ALL CONTENT GOES WITHIN THIS DIV-->
			</div>
			<div class="four columns sideColumn" id="downloads">
				<!-- ALL CONTENT GOES WITHIN THIS DIV-->
				<h2>Downloads</h2>
				<img src="images/arrow.png" alt="arrow" width="18" height="17" />

    <?php foreach ($downloadsRecords as $record): ?>
      Record Number: <?php echo htmlencode($record['num']) ?><br/>
      Title: <?php echo htmlencode($record['title']) ?><br/>
      Include in Footer (value): <?php echo $record['include_in_footer'] ?><br/>
      Include in Footer (text):  <?php echo $record['include_in_footer:text'] ?><br/>
      Summary: <?php echo htmlencode($record['summary']) ?><br/>
      Category (value): <?php echo $record['category'] ?><br/>
      Category (label): <?php echo $record['category:label'] ?><br/>
      Products (values): <?php echo join(', ', $record['products:values']); ?><br/>
      Products (labels): <?php echo join(', ', $record['products:labels']); ?><br/>
      Product Group (values): <?php echo join(', ', $record['product_group:values']); ?><br/>
      Product Group (labels): <?php echo join(', ', $record['product_group:labels']); ?><br/>
      Industry Group (values): <?php echo join(', ', $record['industry_group:values']); ?><br/>
      Industry Group (labels): <?php echo join(', ', $record['industry_group:labels']); ?><br/>
      Applciation Group (values): <?php echo join(', ', $record['applciation_group:values']); ?><br/>
      Applciation Group (labels): <?php echo join(', ', $record['applciation_group:labels']); ?><br/>
      _link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

      <!-- STEP 2a: Display Uploads for field 'file' (Paste this anywhere inside STEP2 to display uploads) -->
        <!-- Upload Fields: extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
        File:
        <blockquote>
        <?php foreach ($record['file'] as $index => $upload): ?>
          Upload Url: <?php echo $upload['urlPath'] ?><br/>

          <!-- Uploads: Copy the tags from below that you want to use, and erase the ones you don't need.
<br/>
          Download Link: <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/><br/>

          Image Tags:<br/>
          <img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

          info1 (File Name) : <?php echo htmlencode($upload['info1']) ?><br/><br/>

          Extension: <?php echo $upload['extension'] ?><br/>
          isImage: <?php if ($upload['isImage']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          hasThumbnail: <?php if ($upload['hasThumbnail']): ?>Yes<?php else: ?>No<?php endif ?><br/>
          <hr/>
          // end uploads comment tag -->

        <?php endforeach ?>
        </blockquote>
      <!-- STEP2a: /Display Uploads -->

      <hr/>
    <?php endforeach ?>

    <?php if (!$downloadsRecords): ?>
      No records were found!<br/><br/>
    <?php endif ?>
  <!-- /STEP2: Display Records -->

				<!-- ALL CONTENT GOES WITHIN THIS DIV-->
			</div>
			<?php include ("_testimonials.php") ?>
		</section>
		

<?php include ("_footer.php") ?>
<?php include ("_bottom.php") ?>
