Toss an afternoon, the Smarty and Html_quikform joined together the source code:
test.php
<?php
Require_once "html/quickform.php";
Require_once ' html/quickform/renderer/arraysmarty.php ';
Require_once ' link/myload.php ';
$form = new Html_quickform (' frmtest ', ' get ');
$form->addelement (' header ', ' hdrtesting ', ' smarty&html/quickform Joint Programming Experiment ') );
$form->addelement (' text ', ' txtFirstName ', ' surname? ');
$form->addelement (' text ', ' txtlastname ', ' respected name? ');
$form->addelement (' text ', ' txtage ', ' age? ');
$form->addelement (' text ', ' txttelephone ', ' phone? ');
$form->addelement (' Reset ', ' btnclear ', ' Reset ');
$form->addelement (' Submit ', ' btnsubmit ', ' submission ');
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
<?php
Load Smarty Library
Define (' Myclude ',/usr/share/php/smarty ');
Require (myinclude. ') /libs/smarty.class.php ');
Setup.php is a good class library file for loading applications (that is, extended classes)
For example, you can include it in the index file.
Class Smarty_my extends Smarty {
function Smarty_my () {
Class constructor. These automatically get sets with each new instance.
Class constructors. Automatic configuration when creating an instance
$this->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 ');
}
}
Template file My.tpl
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<!--$Id: Smarty-guide.tpl,v 1.1 2005/03/03 19:26:54 kae EXP $-->
<link rel= "stylesheet" type= "Text/css" href= "Css/my.css"/>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<body>
<form >
<!--Display The fields-->
<table>
<tr>
<th></th>
<td></td>
<th></th>
<td></td>
</tr>
<tr>
<th></th>
<td></td>
<th></th>
<td></td>
</tr>
<!--Display the buttons-->
<tr>
<TD align= "Center" colspan= "4" >
</td>
</tr>
<!--Display the copyright-->
<tr>
<TD style= "FONT-SIZE:11PX; Color:navy; Text-align:center "colspan=" 4 ">
©2005 Chen Experiment
</td>
</tr>
</table>
Cascading model Table Files 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;
}