SMARTY学习5
从xx.conf里调用的变量 用#XX#来调用pageTitle = "This is mine"bodyBgColor = "#eeeeee"-------------------------------------<body bgcolor="{#bodyBgColor#}"><table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}"><tr bgcolor="{#rowBgColor#}">... « 阅读全文
smarty实例教程(2)
例3使用了一些smarty模板中内置的一些函数,相似的函数大家可以在手册中查到,使用方法很简单,大家可以自己去查找. 例4.模板控制(if / elseif / else/ endif ) ======================================================= example4.tpl ======================================================= <html> <head>&... « 阅读全文
smarty 截取字符串函数 truncate
smarty truncate 截取字符串_始厝∧抽L度的字符.默J是80。你也可以指定第二底樽芳釉诮厝∽址崦娴奈谋咀执.追加字串被算在截取L度中。默J情r下,smarty厝〉揭~的末尾。如果你想要精_的截取多少字符,把第三蹈"true" 。例 截取:index.php:$smarty = new Smarty;$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Check... « 阅读全文
Smarty第一个HelloWorld
我们先设定 Smarty 的路径, main.php: <?php include "class/Smarty.class.php"; define('__SITE_ROOT', 'd:/appserv/web/demo'); // 最后没有斜线 $tpl = new Smarty(); $tpl->template_dir = __SITE_ROOT ."/templates/"; $tpl->compile_dir = __SITE_ROO... « 阅读全文
Smarty中实现模板嵌套
主要从Smarty.class.php的fetch()函数入手先来看看display()函数 functiondisplay($resource_name, $cache_id = null, $compile_id = null) $this->fetch($resource_name,$cache_id, $compile_id, true);这个函数的作用就是向屏幕输出"模板文件"的一个函数.类似这样:$my_smarty->display("... « 阅读全文
Smarty实现HTML静态化页面
<?phprequire_once("./config/config.php");ob_start();$id=$_GET[id];$sql="select * from table_name where id='$id'";$result=mysql_query($sql);$rs=mysql_fetch_object($result);$smarty->assign("showtitle",$rs->title);$smarty->assign("showcont... « 阅读全文
在Zend_Framework中结合Zend_Paginator和Smarty实现分页(图)
在一般的Web程序中都要用到分页的功能。对于使用了Zend框架的Web程序来说,结合Zend自身的View和Zend_Paginator组件,实现分页是比较轻松的事。但在Zend中整合了Smarty模板语言后,又如何使用Zend_Paginator来实现分页呢。其实,我们在分析了Zend_Pagi... « 阅读全文
网码修改:PHP的Smarty入门
下载smarty:http://119.6.30.49:9203/E482782F3B7B90B882B7797354D9769B895CA8EB/www.phpchina.com/manual/smarty/Smarty-2.6.14.tar.gz什么是smarty? Smarty是一个使用PHP写出来的模板PHP模板引擎,由PHP.net官方提供,它提供了逻辑与外在内容的分离,简单的讲,目的就是要使用PHP程序员同美工分离,使用的程序员改变程序的逻辑内容不会影响到美工的页面设计,美工重新... « 阅读全文
smarty中section的嵌套用法
程序部分内容:$query = “SELECT id,name,name_cn FROM di_flag ORDER BY iddesc”;$result = mysql_query($query);while($row = mysql_fetch_array($result)) $query2=”SELECT id, name, name_cn,flag FROM di_sort ... « 阅读全文
Smarty 截取字符串函数 truncate
原有的函数截取中文字符时会出现乱码问题,修改smarty目录下plugins\modifier.truncate.php文件如下function smarty_modifier_truncate($string, $sublen = 80, $etc = '...', $break_words = false, $middle = false){$start=0;$code="UTF-8"; if($code == ... « 阅读全文

