<?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."); }

  // load record from 'news'
  list($newsRecords, $newsMetaData) = getRecords(array(
    'tableName'   => 'news',
    'where'       => whereRecordNumberInUrl(0), // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $newsRecord = @$newsRecords[0]; // get first record
  if (!$newsRecord) { dieWith404("Record not found!"); } // show error message if no record found

?><!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" />
  <style type="text/css">
    body          { font-family: arial; }
    .instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
  </style>
 </head>
<body>

  <!-- INSTRUCTIONS -->
    <div class="instructions">
      <b>Sample Detail Viewer - Instructions:</b>
      <ol>
        <?php /*><li style="color: red; font-weight: bold">Rename this file to have a .php extension!</li><x */ ?>
        <li><b>Remove any fields you don't want displayed.</b></li>
        <li>Rearrange remaining fields to suit your needs.</li>
        <li>Copy and paste code into previously designed page (or add design to this page).</li>
      </ol>
    </div>
  <!-- /INSTRUCTIONS -->

  <!-- STEP2: Display Record (Paste this where you want your record to appear) -->
    <h1>最新消息 - Detail Page Viewer</h1>
      Record Number: <?php echo htmlencode($newsRecord['num']) ?><br/>
      date: <?php echo date("D, M jS, Y g:i:s a", strtotime($newsRecord['date'])) ?><br/><!-- For date formatting codes see: http://www.php.net/date -->
      category (value): <?php echo $newsRecord['category'] ?><br/>
      category (label): <?php echo $newsRecord['category:label'] ?><br/>
      Title: <?php echo htmlencode($newsRecord['title']) ?><br/>
      Content: <?php echo $newsRecord['content']; ?><br/>
      _link : <a href="<?php echo $newsRecord['_link'] ?>"><?php echo $newsRecord['_link'] ?></a><br/>
  <!-- /STEP2: Display Record -->
    <hr/>

  <a href="newslist.php">&lt;&lt; Back to list page</a>
  <a href="mailto:?subject=<?php echo urlencode(thisPageUrl()) ?>">Email this Page</a>

</body>
</html>
