home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / smarty-dynamic.tpl < prev    next >
Encoding:
Text File  |  2004-03-24  |  4.0 KB  |  140 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <!--  $Id: smarty-dynamic.tpl,v 1.3 2003/05/21 13:27:59 avb Exp $ -->
  3. <html>
  4. <head>
  5.     <title>Smarty template for Array renderer</title>
  6.     <style type="text/css">
  7.     {literal}
  8.     body, td, th {
  9.        font-family: sans-serif;
  10.        color : Navy;
  11.        background-color : #EEE;
  12.        font-size : smaller;
  13.        white-space: nowrap;
  14.     }
  15.     
  16.     .maintable {
  17.        border : thin dashed #D0D0D0;
  18.        background-color : #EEE;
  19.     }
  20.     
  21.     .header {
  22.        color : #FFF;
  23.        background-color : #999;
  24.     }
  25.     
  26.     .green {
  27.        background-color : #CFC;
  28.        color : black;
  29.     }
  30.     {/literal}
  31.     </style>
  32.     
  33. </head>
  34. <body>
  35.  
  36. {if $form.javascript}
  37. <script language="javascript">
  38. <!-- 
  39.     {$form.javascript}
  40. //-->
  41. </script>
  42. {/if}
  43.  
  44. <table border="0" class="maintable" align="center">
  45.     <form{$form.attributes}>{$form.hidden}
  46.     
  47.     {foreach item=sec key=i from=$form.sections}
  48.         <tr>
  49.             <td class="header" colspan="2">
  50.             <b>{$sec.header}</b></td>
  51.         </tr>
  52.               
  53.         {foreach item=element from=$sec.elements}
  54.             
  55.             <!-- elements with alternative layout in external template file-->
  56.             {if $element.style}
  57.                 {include file="smarty-dynamic-`$element.style`.tpl} 
  58.                 
  59.             {*
  60.             NOTE: Another way ist to have smarty template code in
  61.             $element.style. In this case you can do:
  62.             
  63.             {if $element.style}
  64.                 {eval var=$element.style}
  65.             *}   
  66.             
  67.             <!-- submit or reset button (don't display on frozen forms) -->
  68.             {elseif $element.type eq "submit" or $element.type eq "reset"}
  69.                 {if not $form.frozen}
  70.                 <tr>   
  71.                     <td> </td>
  72.                     <td align="left">{$element.html}</td>
  73.                 </tr>
  74.                 {/if}
  75.             
  76.             <!-- normal elements -->
  77.             {else}
  78.                 <tr>
  79.                 {if $element.type eq "textarea"}               
  80.                     <td colspan="2">
  81.                         {if $element.required}<font color="red">*</font>{/if}<b>{$element.label}</b><br />
  82.                 {else}
  83.                     <td align="right" valign="top">
  84.                         {if $element.required}<font color="red">*</font>{/if}<b>{$element.label}:</b></td>
  85.                     <td>
  86.                 {/if} 
  87.                     {if $element.error}<font color="red">{$element.error}</font><br />{/if}
  88.                     {if $element.type eq "group"}
  89.                         {foreach key=gkey item=gitem from=$element.elements}
  90.                             {$gitem.label}
  91.                             {$gitem.html}{if $gitem.required}<font color="red">*</font>{/if}                           
  92.                             {if $element.separator}{cycle values=$element.separator}{/if}
  93.                         {/foreach}
  94.                     {else}
  95.                         {$element.html}
  96.                     {/if}
  97.                     </td>
  98.                 </tr>
  99.             
  100.             {/if}
  101.         {/foreach}   
  102.     {/foreach}
  103.     
  104.     {if $form.requirednote and not $form.frozen}
  105.     <tr>
  106.         <td> </td>
  107.         <td valign="top">{$form.requirednote}</td>
  108.     </tr>
  109.     {/if}
  110.     
  111.     </form>   
  112. </table>
  113.  
  114.  
  115. <p><b>Collected Errors:</b><br />
  116. {foreach key=name item=error from=$form.errors}
  117.     <font color="red">{$error}</font> in element [{$name}]<br />
  118. {/foreach}
  119. </p>
  120.  
  121.  
  122. <p><strong>Best Practice: </strong><br />
  123. Use only one dynamic form template like this for your <br />
  124. Smarty driven project. You include this where <br />
  125. to place a form with the formdata-Array rendered by <br />
  126. SmartyDynamic QuickForm Renderer as option:</p>
  127.  
  128. <pre style="font-size: 12px;">
  129. <strong>{ldelim}include file=form-dynamic.tpl form=$formdata{rdelim}</strong>
  130. </pre>
  131.  
  132.  
  133. <p><strong>The used "Dynamic" Array </strong></p>
  134. <pre style="font-size: 12px;">
  135. {$dynamic_array|htmlentities}
  136. </pre>
  137.  
  138. </body>
  139. </html>
  140.