mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-04 06:11:37 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			348 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			348 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<sect1 id="language.function.html.select.date">
 | 
						|
 <title>{html_select_date}</title>
 | 
						|
  <para>
 | 
						|
   <varname>{html_select_date}</varname> is a
 | 
						|
   <link linkend="language.custom.functions">custom function</link>
 | 
						|
   that creates date dropdowns.
 | 
						|
   It can display any or all of year, month, and day.
 | 
						|
  All parameters that are not in the list below are printed as
 | 
						|
  name/value-pairs inside the <literal><select></literal> tags
 | 
						|
  of day, month and  year.
 | 
						|
 </para>
 | 
						|
 | 
						|
 <informaltable frame="all">
 | 
						|
  <tgroup cols="5">
 | 
						|
   <colspec colname="param" align="center" />
 | 
						|
   <colspec colname="type" align="center" />
 | 
						|
   <colspec colname="required" align="center" />
 | 
						|
   <colspec colname="default" align="center" />
 | 
						|
   <colspec colname="desc" />
 | 
						|
   <thead>
 | 
						|
    <row>
 | 
						|
     <entry>Attribute Name</entry>
 | 
						|
     <entry>Type</entry>
 | 
						|
     <entry>Required</entry>
 | 
						|
     <entry>Default</entry>
 | 
						|
     <entry>Description</entry>
 | 
						|
    </row>
 | 
						|
   </thead>
 | 
						|
   <tbody>
 | 
						|
    <row>
 | 
						|
     <entry>prefix</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>Date_</entry>
 | 
						|
     <entry>What to prefix the var name with</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>time</entry>
 | 
						|
     <entry>timestamp/ YYYY-MM-DD</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>current time in unix timestamp or YYYY-MM-DD format</entry>
 | 
						|
     <entry>What date/time to use</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>start_year</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>current year</entry>
 | 
						|
     <entry>The first year in the dropdown, either
 | 
						|
      year number, or relative to current year (+/- N)</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>end_year</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>same as start_year</entry>
 | 
						|
     <entry>The last year in the dropdown, either
 | 
						|
      year number, or relative to current year (+/- N)</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>display_days</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>&true;</entry>
 | 
						|
     <entry>Whether to display days or not</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>display_months</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>&true;</entry>
 | 
						|
     <entry>Whether to display months or not</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>display_years</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>&true;</entry>
 | 
						|
     <entry>Whether to display years or not</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>month_format</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>%B</entry>
 | 
						|
     <entry>What format the month should be in (strftime)</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>day_format</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>%02d</entry>
 | 
						|
     <entry>What format the day output should be in (sprintf)</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>day_value_format</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>%d</entry>
 | 
						|
     <entry>What format the day value should be in (sprintf)</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>year_as_text</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>&false;</entry>
 | 
						|
     <entry>Whether or not to display the year as text</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>reverse_years</entry>
 | 
						|
     <entry>boolean</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>&false;</entry>
 | 
						|
     <entry>Display years in reverse order</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>field_array</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>
 | 
						|
      If a name is given, the select boxes will be drawn
 | 
						|
      such that the results will be returned to PHP in the
 | 
						|
      form of name[Day], name[Year], name[Month].
 | 
						|
     </entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>day_size</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds size attribute to select tag if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>month_size</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds size attribute to select tag if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>year_size</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds size attribute to select tag if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>all_extra</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds extra attributes to all select/input tags if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>day_extra</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds extra attributes to select/input tags if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>month_extra</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds extra attributes to select/input tags if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>year_extra</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>Adds extra attributes to select/input tags if given</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>field_order</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>MDY</entry>
 | 
						|
     <entry>The order in which to display the fields</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>field_separator</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>\n</entry>
 | 
						|
     <entry>String printed between different fields</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>month_value_format</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>%m</entry>
 | 
						|
     <entry>strftime() format of the month values, default is
 | 
						|
      %m for month numbers.</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>year_empty</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>If supplied then the first element of the year's select-box has this
 | 
						|
     value as it's label and <quote></quote> as it's value. This is useful to make the
 | 
						|
     select-box read <quote>Please select a year</quote> for example.
 | 
						|
     Note that you can use values like <quote>-MM-DD</quote> as time-attribute to indicate
 | 
						|
     an unselected year.</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>month_empty</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>If supplied then the first element of the month's select-box has this
 | 
						|
     value as it's label and <quote></quote> as it's value. .
 | 
						|
     Note that you can use values like <quote>YYYY--DD</quote> as time-attribute to indicate
 | 
						|
     an unselected month.</entry>
 | 
						|
    </row>
 | 
						|
    <row>
 | 
						|
     <entry>day_empty</entry>
 | 
						|
     <entry>string</entry>
 | 
						|
     <entry>No</entry>
 | 
						|
     <entry>null</entry>
 | 
						|
     <entry>If supplied then the first element of the day's select-box has this
 | 
						|
     value as it's label and <quote></quote> as it's value.
 | 
						|
     Note that you can use values like <quote>YYYY-MM-</quote> as
 | 
						|
     time-attribute to indicate  an unselected day.</entry>
 | 
						|
    </row>
 | 
						|
   </tbody>
 | 
						|
  </tgroup>
 | 
						|
 </informaltable>
 | 
						|
 | 
						|
 <note>
 | 
						|
  <para>
 | 
						|
   There is an useful php function on the
 | 
						|
   <link linkend="tips.dates">date tips page</link> for converting
 | 
						|
   <varname>{html_select_date}</varname> form values to a timestamp.
 | 
						|
  </para>
 | 
						|
 </note>
 | 
						|
 | 
						|
 <example>
 | 
						|
  <title>{html_select_date}</title>
 | 
						|
  <para>Template code</para>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
{html_select_date}
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   This will output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
<select name="Date_Month">
 | 
						|
<option value="1">January</option>
 | 
						|
<option value="2">February</option>
 | 
						|
<option value="3">March</option>
 | 
						|
  ..... snipped .....
 | 
						|
<option value="10">October</option>
 | 
						|
<option value="11">November</option>
 | 
						|
<option value="12" selected="selected">December</option>
 | 
						|
</select>
 | 
						|
<select name="Date_Day">
 | 
						|
<option value="1">01</option>
 | 
						|
<option value="2">02</option>
 | 
						|
<option value="3">03</option>
 | 
						|
  ..... snipped .....
 | 
						|
<option value="11">11</option>
 | 
						|
<option value="12">12</option>
 | 
						|
<option value="13" selected="selected">13</option>
 | 
						|
<option value="14">14</option>
 | 
						|
<option value="15">15</option>
 | 
						|
  ..... snipped .....
 | 
						|
<option value="29">29</option>
 | 
						|
<option value="30">30</option>
 | 
						|
<option value="31">31</option>
 | 
						|
</select>
 | 
						|
<select name="Date_Year">
 | 
						|
<option value="2006" selected="selected">2006</option>
 | 
						|
</select>
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
 </example>
 | 
						|
 | 
						|
 <example>
 | 
						|
  <title>{html_select_date} second example</title>
 | 
						|
  <programlisting>
 | 
						|
<![CDATA[
 | 
						|
{* start and end year can be relative to current year *}
 | 
						|
{html_select_date prefix='StartDate' time=$time start_year='-5'
 | 
						|
   end_year='+1' display_days=false}
 | 
						|
]]>
 | 
						|
  </programlisting>
 | 
						|
  <para>
 | 
						|
   With  2000 as the current year the output:
 | 
						|
  </para>
 | 
						|
  <screen>
 | 
						|
<![CDATA[
 | 
						|
<select name="StartDateMonth">
 | 
						|
<option value="1">January</option>
 | 
						|
<option value="2">February</option>
 | 
						|
.... snipped ....
 | 
						|
<option value="11">November</option>
 | 
						|
<option value="12" selected="selected">December</option>
 | 
						|
</select>
 | 
						|
<select name="StartDateYear">
 | 
						|
<option value="1995">1995</option>
 | 
						|
.... snipped ....
 | 
						|
<option value="1999">1999</option>
 | 
						|
<option value="2000" selected="selected">2000</option>
 | 
						|
<option value="2001">2001</option>
 | 
						|
</select>
 | 
						|
]]>
 | 
						|
  </screen>
 | 
						|
 </example>
 | 
						|
 <para>
 | 
						|
  See also
 | 
						|
  <link linkend="language.function.html.select.time"><varname>{html_select_time}</varname></link>,
 | 
						|
  <link linkend="language.modifier.date.format"><varname>date_format</varname></link>,
 | 
						|
  <link linkend="language.variables.smarty.now"><parameter>$smarty.now</parameter></link>
 | 
						|
  and the <link linkend="tips.dates">date tips page</link>.
 | 
						|
 </para>
 | 
						|
</sect1>
 | 
						|
 | 
						|
<!-- Keep this comment at the end of the file
 | 
						|
Local variables:
 | 
						|
mode: sgml
 | 
						|
sgml-omittag:t
 | 
						|
sgml-shorttag:t
 | 
						|
sgml-minimize-attributes:nil
 | 
						|
sgml-always-quote-attributes:t
 | 
						|
sgml-indent-step:1
 | 
						|
sgml-indent-data:t
 | 
						|
indent-tabs-mode:nil
 | 
						|
sgml-parent-document:nil
 | 
						|
sgml-default-dtd-file:"../../../../manual.ced"
 | 
						|
sgml-exposed-tags:nil
 | 
						|
sgml-local-catalogs:nil
 | 
						|
sgml-local-ecat-files:nil
 | 
						|
End:
 | 
						|
vim600: syn=xml fen fdm=syntax fdl=2 si
 | 
						|
vim: et tw=78 syn=sgml
 | 
						|
vi: ts=1 sw=1
 | 
						|
-->
 | 
						|
 |