Smarty instance tutorial - template design section -2
Author: teacherlxj Document Type: Posted Visitor Statistics: 242 Source: 9cbs Time: 2004-08-22 08:40:02 instance 3. ==================== ============================== Example3.tpl =============== ============================================ Some functions title> head> {* The following paragraph is equivalent to defining a variable in the template UserName *} {Assign var = "username" value = "Master" \ = $ Checkname Checked = $ ischecked Output = $ VALUE SEPARATOR = "
" {{html_radioes name = "radiobox" value <
Copyright (c) by xiaojun, Li 2004 {mailto address = "teacherli@163.ccom" Text = "Contact the author"} body> =================================================
==== example3.php =========================================== ============ PHP / ***************************************** ************ * * * File name: example3.php * Email: ********* / Require_once ("./comm/smarty.class.php"); $ smarty = new f117_smarty; $ smarty-> template_dir = './Templates/'; $ smarty-> compile_dir = './Templates_C/'; $ smarty-> config_dir = './configs/'; $ smarty-> cache_dir = './cache/'; $ smarty-> caching = false; // -------------------------------------------------- ------------------------------------ // Handle {HTML_CHECKBOXES name = "checkbox" value = $ checkname Checked = $ ischecked Output = $ value separator = "
"} // ------------------------------- -------------------------------------------------- ----- $ Smarty-> Assign ('Checkname ", Array ( =>" => => '外语')); $ smarty-> assign ('ischecked', 1001); // - -------------------------------------------------- ----------------------------------- // Handle {HTML_RADIOES Name = "Radiobox" VALUES = $ radioname checked = $ IsChecked Output = $ value separator = "
"
} // ----------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------- $ Smarty-> Assign ('Radioname ", Array ( ? ', 1001); // ------------------------------------------- ------------------------------------------ // {html_select_date} No processing Automatic output // ------------------------------------------- ----------------------------------------- .tpl ");?> =========================================== =========== xPLE3.PHP output effect: ================================= ====================== Some functions in the template title> head>
{Assign Var = "username" value = "Master" Username = Master Master BR>
language
Mathematics
Foreign language <
BR /> below this line will display 3 Radio:
Mathematics
Foreign language
The following shows a month, day, annual selection box: