diff --git a/Smarty.addons.php b/Smarty.addons.php index a1d91e90..0e85e9f4 100644 --- a/Smarty.addons.php +++ b/Smarty.addons.php @@ -273,6 +273,16 @@ function smarty_func_html_select_date() print $html_result; } +/*======================================================================*\ + Function: smarty_func_header + Purpose: Pass a header. Must be used before any content is sent. +\*======================================================================*/ +function smarty_func_header($params) +{ + extract($params); + header($contents); +} + /* vim: set expandtab: */ ?> diff --git a/Smarty.class.php b/Smarty.class.php index f17ecde1..6a2c279e 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -76,7 +76,8 @@ class Smarty var $custom_funcs = array( 'html_options' => 'smarty_func_html_options', - 'html_select_date' => 'smarty_func_html_select_date' + 'html_select_date' => 'smarty_func_html_select_date', + 'header' => 'smarty_func_header' ); var $custom_mods = array( 'lower' => 'strtolower', diff --git a/docs.sgml b/docs.sgml index 98874efc..0d75456c 100644 --- a/docs.sgml +++ b/docs.sgml @@ -1711,8 +1711,7 @@ OUTPUT: Custom Functions Custom functions in Smarty work much the same as the built-in functions - syntactically. Two custom functions come bundled with Smarty. You can - also write your own. + syntactically. html_options @@ -1736,14 +1735,14 @@ OUTPUT: values array - No, if using options attribute + Yes, unless using options attribute n/a an array of values for dropdown output array - No, if using options attribute + Yes, unless using options attribute n/a an array of output for dropdown @@ -1757,7 +1756,7 @@ OUTPUT: options associative array - No, if using values and output + Yes, unless using values and output n/a an associative array of values and output @@ -1996,6 +1995,71 @@ OUTPUT: <option value="2001">2001</option> </select> + + + + + header + + + + + + + + + + Attribute Name + Type + Required + Default + Description + + + + + contents + string + Yes + n/a + The contents of the header to pass + + + + + + header is a function that passes a raw header + string to the output. If your template is used for WAP (Wireless + Access Protocol) for example, you would need to send a special + header to indicate the type of content you are sending. + + + TECHNICAL NOTE: Be sure you call {header ...} + before any output in your template, in + including whitespace. Otherwise the header will not work as + intended. + + +header + + +{* our template is outputting contents for WAP devices *} +{header contents="Content-type: text/vnd.wap.wml"} + +<?xml version"1.0"?> +DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" +"http://www.wapforum.org/DTD/wml_1.1.xml" + +<wml> +<card id="card1" title="Example1"> + <p> + {$now|date_format} + Welcome to my webpage! + </p> +</card> +</wml> + + diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index f17ecde1..6a2c279e 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -76,7 +76,8 @@ class Smarty var $custom_funcs = array( 'html_options' => 'smarty_func_html_options', - 'html_select_date' => 'smarty_func_html_select_date' + 'html_select_date' => 'smarty_func_html_select_date', + 'header' => 'smarty_func_header' ); var $custom_mods = array( 'lower' => 'strtolower',