<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "admin/lib/viewer_functions.php";
  
  list($categoriesRecords, $selectedCategory) = getCategories(array( 
    'tableName'   => 'categories', 
  )); 

  list($articlesRecords, $articlesMetaData) = getRecords(array(
    'tableName'   => 'articles',
	'perPage'     => '6',
  ));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="776" height="374" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="154">
    <ul>
              <?php foreach ($categoriesRecords as $categoryRecord): ?>
              <?php echo $categoryRecord['_listItemStart'] ?><?php if ($categoryRecord['_isSelected']): ?><u><?php endif ?>
<a href=""><?php echo $categoryRecord['name'] ?></a><?php if ($categoryRecord['_isSelected']): ?></u><?php endif ?><?php echo $categoryRecord['_listItemEnd'] ?>
              <?php endforeach ?>
      </ul>    </td>
    <td width="53">&nbsp;</td>
    <td width="569">
    
            <h2>
            <?php if ($selectedCategory): ?>
           <?php echo $selectedCategory['name'] ?> 
           <?php endif; ?>
           </h2>
           
           <ul>
            <?php foreach ($articlesRecords as $record): ?>
            <li>
              <table width="135" border="0" cellspacing="0" cellpadding="0">
                <tr><td><h3 align="center" ><?php echo $record['number'] ?></h3></td></tr>
                <tr><td><?php foreach ($record['image'] as $upload): ?><a href="<?php echo $upload['urlPath'] ?>" title="<?php echo $record['description'] ?>"> <img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" /><?php endforeach ?></a> </td></tr>
              </table>
            </li>
            <?php endforeach ?>
          </ul>
          <?php if (!$articlesRecords): ?>
          No articles in this Category !<br/>
          <br/>
          <?php endif ?>    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>
    
    <div align="center">
            <?php if ($articlesMetaData['prevPage']): ?>
            <a href="<?php echo $articlesMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
            <?php else: ?>
            &lt;&lt; prev
            <?php endif ?>
            - page <?php echo $articlesMetaData['page'] ?> of <?php echo $articlesMetaData['totalPages'] ?> -
            <?php if ($articlesMetaData['nextPage']): ?>
            <a href="<?php echo $articlesMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
            <?php else: ?>
            next &gt;&gt;
            <?php endif ?>
          </div>
    
    </td>
  </tr>
</table>
</body>
</html>
