Smarty(PHP)
SmartySmarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. This is best described in a situation where the application programmer and the template designer play different roles, or in most cases are not the same person.
Homepage: http://smarty.php.net/
在php中配置使用smarty模板引擎
Smarty是php的半官方模板引擎,从其主页位置就可以看出。使用简单,功能强大,本文就介绍一下smarty模板的安装和使用。 1) 现在模板的安装包,解压到根目录外的某个位置,比如解压到c:\phpLib\smarty 2)修改 php.ini文件,配置include_path。 如此文中的配置为:include_path="c:\phpLib\smarty\libs" 注意,要把...
Smarty之foreach心得
<?php require_once('./Smarty/libs/Smarty.class.php'); $db_host='localhost'; $db_user='root'; $db_password=''; $db_name='test'; mysql_connect($db_host,$db_user,$db_password); //连接数据库 mysql_select_db($db_name); //选择数据库 $sql="select * from posts"; $result=mysql_query($sql); //查询 $sma...
今天的smarty心得
{* section函数的基本使用方法*} 函数体: {section name=customer loop=$custid} id: {$custid[customer]}<br> {/section} //customer为该section的名称,$custid为section要循环的数组 //section的第一种写法:$custid[customer],即所循环的数组[section名称].所循环数组的参数。 输出: id: 1000<br> id: 1001...
调试smarty模板时,查看变量的方法
调试smarty模板时,查看变量的方法 一直想知道最近才知道的。 如果你在使用smarty时,想查看某变量的内容,而又不想打开smarty debug,或smarty debug的输出不能满足你的要求,可以这样用。 {$var|print_r} 如果是数组,应当 {$var|@print_r} 这里用@是来保证把变量当做一个整体对待,否则会遍历这个array 当然,在fleaphp中,要这...
php smarty 入门教程
形势所迫,决定开始学习smarty,不管怎么样帖起来先! 转自:网络(因为原创是谁偶也不晓得) 一、什么是smarty? smarty是一个使用PHP写出来的模板PHP模板引擎,它提供了逻辑与外在内容的分离,简单的讲,目的就是要使用PHP程序员同美工分 离,使用的程序员改变程序的逻辑内容不会影响到美工的页面设计,美工重新修改页面不会影响到程序的程序逻...
winxp+Apache2+php5环境smarty安装
1、下载Smarty包 可以从官方站点下载:http://smarty.php.net/ 2、解压缩Smarty包 解压后的文件夹重命名为Smarty,放置在C:\Apache2\include下 3、修改配置文件php.ini的include_path选项,把smarty的库文件路径加上 include_path = “C:\Apache2\include\Smarty\libs” 4、在你的网站目录下创建一个文件夹smarty: 然后再在这个Smarty目录...
cakephp+smarty循环输出数据
cakephp的model关联复杂,需要一个model的数据时,其它相关联的model都出来了,造成smarty循环打印数据不方便 实验了一会,发现用samrty里的section语句可以达到.还是比较麻烦的. 假如想得到 " LinkCategory表" 下的分类的名字, 和与该分类相关联的 " Links表" 下的item . &nb...
smarty扩展编写简介
给smarty写扩展是很简单的事情 1 配置 首先 需要在配置部分,指定插件目录,如果你放到默认的插件目录下,这一步可以省略: $this->plugins_dir[] = ROOT . ‘lib/smarty_plugin’; 2 文件命名 然后开始命名扩展函数的文件名称,名称的规范是 function.name.php,如 function.lang.php 3 函数命名 建立这个文件后就可以开始写函数了...
Smarty 中的 if 语句条件修饰词
Smarty 中的 if 语句和 php 中的 if 语句一样灵活易用,并增加了几个特性以适宜模板引擎. if 必须于 /if 成对出现. 可以使用 else 和 elseif 子句. 可以使用以下条件修饰词:eq、ne、neq、gt、lt、lte、le、gte、ge、is even、is odd、is not even、is not odd、not、mod、div by、even by、odd by、==、!=、>、<、<=、>=. 使用这些修饰词时必须和...