<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/httpd/vhosts/kwbs.org.tw/httpdocs/web/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  list($categoryRecords, $selectedCategory) = getCategories(array(
    'tableName'           => 'category',
    'selectedCategoryNum' => '',         // defaults to getNumberFromEndOfUrl()
    'categoryFormat'      => 'showall',  // showall, onelevel, twolevel
  ));

?>
<?php echo "<?xml version='1.0'?>\n"; ?>
<!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>
  <title></title>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

</head>
  <body>
  <table border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td valign="top" width="200"><!-- category menu -->
        
        <h3>Nested Menu</h3>
        <?php foreach ($categoryRecords as $categoryRecord): ?>
        <?php echo str_repeat("&nbsp; &nbsp; &nbsp;", $categoryRecord['depth']); ?>
        <?php if ($categoryRecord['_isSelected']): ?>
        <b>
        <?php endif; ?>
        <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
        <?php if ($categoryRecord['_isSelected']): ?>
        </b>
        <?php endif; ?>
        <br/>
        <?php endforeach; ?>
        
        <!-- /category menu --> 
        
        <br/>
        <br/>
        <h3>Unorder List Menu</h3>
        
        <!-- unordered list -->
        
        <ul>
          <?php foreach ($categoryRecords as $categoryRecord): ?>
          <?php echo $categoryRecord['_listItemStart'] ?>
          <?php if ($categoryRecord['_isSelected']): ?>
          <b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a></b>
          <?php else: ?>
          <a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
          <?php endif; ?>
          <?php echo $categoryRecord['_listItemEnd'] ?>
          <?php endforeach; ?>
        </ul>
        
        <!-- /unordered list --></td>
      <td valign="top"><?php if (!$selectedCategory): ?>
        No record selected
        <?php endif; ?>
        <?php if ($selectedCategory): ?>
        <h3><?php echo $selectedCategory['name'] ?></h3>
        <?php echo $selectedCategory['content'] ?>
        <?php endif; ?></td>
    </tr>
  </table>
</body>
</html>
