王朝网络
分享
 
 
 

smarty和html_QuikForm联合编程

王朝html/css/js·作者佚名  2006-01-10
宽屏版  字体: |||超大  

折腾一个下午,把smarty和html_QuikForm联结到一起了源码:

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联合编程实验');

$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

<?php

// load Smarty library

define('myclude',/usr/share/php/smarty');

require(myinclude.'/libs/Smarty.class.php');

//setup.php是一个很好的加载应用程序的类库文件(就是扩展类)

//例如你可以在index文件里包含它

class Smarty_my extends Smarty {

function Smarty_my() {

// Class Constructor. These automatically get set with each new 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');

}

}

模板文件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 $ -->

<head>

<link rel="stylesheet" type="text/css" href="css/my.css" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >

</head>

<body>

<h2>

</h2>

<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">

&nbsp;

</td>

</tr>

<!-- Display the copyright -->

<tr>

<td style="font-size:11px; color: navy; text-align: center" colspan="4">

&copy;2005 陈刚 实验

</td>

</tr>

</table>

层叠式样表文件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;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有