library/smarty/demo/templates/index.tpl
changeset 46 f11c31f7fa3e
parent 45 a56e7f9a0463
child 47 03388ec805b4
equal deleted inserted replaced
45:a56e7f9a0463 46:f11c31f7fa3e
     1 {config_load file="test.conf" section="setup"}
       
     2 {include file="header.tpl" title=foo}
       
     3 
       
     4 <PRE>
       
     5 
       
     6 {* bold and title are read from the config file *}
       
     7     {if #bold#}<b>{/if}
       
     8         {* capitalize the first letters of each word of the title *}
       
     9         Title: {#title#|capitalize}
       
    10         {if #bold#}</b>{/if}
       
    11 
       
    12     The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
       
    13 
       
    14     The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
       
    15 
       
    16     Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
       
    17 
       
    18     The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
       
    19 
       
    20 variable modifier example of {ldelim}$Name|upper{rdelim}
       
    21 
       
    22 <b>{$Name|upper}</b>
       
    23 
       
    24 
       
    25 An example of a section loop:
       
    26 
       
    27     {section name=outer
       
    28     loop=$FirstName}
       
    29         {if $smarty.section.outer.index is odd by 2}
       
    30             {$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
       
    31         {else}
       
    32             {$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
       
    33         {/if}
       
    34         {sectionelse}
       
    35         none
       
    36     {/section}
       
    37 
       
    38     An example of section looped key values:
       
    39 
       
    40     {section name=sec1 loop=$contacts}
       
    41         phone: {$contacts[sec1].phone}
       
    42         <br>
       
    43 
       
    44 
       
    45 
       
    46                                     fax: {$contacts[sec1].fax}
       
    47 
       
    48 
       
    49         <br>
       
    50 
       
    51 
       
    52 
       
    53                                     cell: {$contacts[sec1].cell}
       
    54 
       
    55 
       
    56         <br>
       
    57     {/section}
       
    58     <p>
       
    59 
       
    60         testing strip tags
       
    61         {strip}
       
    62 <table border=0>
       
    63     <tr>
       
    64         <td>
       
    65             <A HREF="{$SCRIPT_NAME}">
       
    66                 <font color="red">This is a test </font>
       
    67             </A>
       
    68         </td>
       
    69     </tr>
       
    70 </table>
       
    71     {/strip}
       
    72 
       
    73 </PRE>
       
    74 
       
    75 This is an example of the html_select_date function:
       
    76 
       
    77 <form>
       
    78     {html_select_date start_year=1998 end_year=2010}
       
    79 </form>
       
    80 
       
    81 This is an example of the html_select_time function:
       
    82 
       
    83 <form>
       
    84     {html_select_time use_24_hours=false}
       
    85 </form>
       
    86 
       
    87 This is an example of the html_options function:
       
    88 
       
    89 <form>
       
    90     <select name=states>
       
    91         {html_options values=$option_values selected=$option_selected output=$option_output}
       
    92     </select>
       
    93 </form>
       
    94 
       
    95 {include file="footer.tpl"}