折腾一个下午,把smarty和html_quikform联结到一起了源码:
test.php
addelement('header', 'hdrtesting', 'smarty&html/quickform联合编程实验');
$form->addelement('text', 'txtfirstname', '贵姓?');
$form->addelement('text', 'txtlastname', '尊名?');
$form->addelement('text', 'txtage', '年龄?');
$form->addelement('text', 'txttelephone', '电话?');
$form->addelement('reset', 'btnclear', '复位');
$form->addelement('submit', 'btnsubmit', '提交');
if ($form->validate()) {
# if the form validates then freeze the data
$form->freeze();
}
// create the template object
$tpl =$smarty=& new smarty_my;
$tpl->compile_check = true;
// create the renderer object
$renderer =& new html_quickform_renderer_arraysmarty($tpl);
// build the html for the form
$form->accept($renderer);
// assign array with form data
$tpl->assign('form_data', $renderer->toarray());
// parse and display the template
$tpl->display('my.tpl');
?>
mylink.php
smarty();
$this->template_dir = '/var/www/apache2-default/smarty/xsgl/templates/';
$this->compile_dir = '/var/www/apache2-default/smarty/xsgl/templates_c/';
$this->config_dir = '/var/www/apache2-default/smarty/xsgl/configs/';
$this->cache_dir = '/var/www/apache2-default/smarty/xsgl/cache/';
$this->caching = true;
$this->assign('app_name','xsgl');
}
}
模板文件my.tpl
©2005 陈刚 实验
层叠式样表文件my.css
body {
background-color: #10f2e7;
}
table
n {
font-size: small;
font-family: arial, helvetica, sans-serif;
}
table {
overflow: scroll;
margin: 0.1px;
font-weight: lighter;
font-family: arial, helvetica, sans-serif;
}