display

显示

void display(string

template [, string cache_id [, string compile_id]])

This displays the template. Supply a valid template resource type and path. As

an optional second parameter, you can pass a cache id. See the caching section for more information.

显示模板,需要指定一个合法的模板资源的类型和路径。你还可以通过

第二个可选参数指定一个缓存号,相关的信息可以查看缓存。

As an optional third parameter, you can pass a compile id. This is

in the event that you want to compile different versions of the same

template, such as having separate templates compiled for different

languages. Another use for compile_id is when you use more than one

$template_dir but only one $compile_dir. Set a separate compile_id for

each $template_dir, otherwise templates of the same name will overwrite

each other. You can also set the $compile_id

variable once instead of passing this to each call to display().

通过第三个可选参数,可以指定一个编译号。这在你想把一个模板编译成不同版本时使用,比如针对不同的语言编译模板。编译号的另外一个作用是,如果你

有多个$template_dir模板目录,但只有一个$compile_dir编译后存档目录,这时可以为每一个$template_dir模板目录指

定一个编译号,以避免相同的模板文件在编译后会互相覆盖。相对于在每一次调用display()的时候都指定编译号,也可以通过设置$compile_id编译号属性来一次性设定。

Example 13-12. display

例子 13-12. 显示

include("Smarty.class.php");

$smarty = new Smarty;

$smarty->caching = true;

// only do db calls if cache doesn't exist

// 只有在缓存不存在时才调用数据库

if(!$smarty->is_cached("index.tpl"))

{

// dummy up some data

$address = "245 N 50th";

$db_data = array(

"City" => "Lincoln",

"State" => "Nebraska",

"Zip" = > "68502"

);

$smarty->assign("Name","Fred");

$smarty->assign("Address",$address);

$smarty->assign($db_data);

}

// display the output

// 显示输出

$smarty->display("index.tpl");

Use the syntax for template

resources to display files outside of the $template_dir directory.

通过模板资源的语法来使用不在$template_dir模板目录

下的文件。

Example 13-13. function display template resource examples

例子 13-13. 显示模板资源

// absolute filepath

// 绝对路径

$smarty->display("/usr/local/include/templates/header.tpl");

// absolute filepath (same thing)

// 绝对路径(另外一种方式)

$smarty->display("file:/usr/local/include/templates/header.tpl");

// windows absolute filepath (MUST use "file:" prefix)

// WINDOS平台下的绝对路径(必须使用“file:”前缀)

$smarty->display("file:C:/www/pub/templates/header.tpl");

// include from template resource named "db"

// 从模板资源“db“中调用

$smarty->display("db:header.tpl");

php $smarty-display,display - [ smarty完全中文手册 ] - 在线原生手册 - php中文网相关推荐

  1. php recordarray,Array 数组 - [ php中文手册 ] - 在线原生手册 - php中文网

    用户评论: [#1] florenxe [2015-10-07 18:53:45] //a nice little way to print leap years using array for ($ ...

  2. android gravity参数,Gravity - [ Android中文手册 ] - 在线原生手册 - php中文网

    Gravity 版本:Android 4.0 r1 结构 继承关系 public class Gravity extends Object java.lang.Object android.view. ...

  3. php gridview,GridView - [ Android中文手册 ] - 在线原生手册 - php中文网

    GridView 版本:Android 2.2 r1 public final class GridView extendsAbsListView java.lang.Object android.v ...

  4. c语言fsetpos是什么,fsetpos - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

    在头文件中定义int fsetpos(FILE * stream,const fpos_t * pos); stream根据指向的值设置文件流的文件位置指示符和多字节解析状态(如果有)pos. 除了建 ...

  5. c语言中mw shl code,cacoshl - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

    在头文件中定义float complex       cacoshf( float complex z );(1)(since C99) double complex      cacosh( dou ...

  6. php vprintf,vprintf - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

    格式-指向以空字符结尾的字符串的指针,指定如何解释数据.格式字符串由普通的多字节字符(%除外)组成,它们被原样复制到输出流和转换规范中.每个转换规范具有以下格式:介绍%字符(可选)一个或多个标志,用于 ...

  7. cbrt c语音_isgraph - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

    在头文件中定义int isgraph(int ch); 检查给定字符是否具有图形表示形式,即它是数字(0123456789),大写字母(ABCDEFGHIJKLMNOPQRSTUVWXYZ),小写字母 ...

  8. c语言L文件,frexpl - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

    在头文件中定义float frexpf(float arg,int * exp);(1)(自C99以来) double frexp(double arg,int * exp);(2) long dou ...

  9. php @touch,touch - [ php中文手册 ] - 在线原生手册 - php中文网

    用户评论: [#1] csouth at xistins dot com [2014-12-14 08:41:04] An earlier comment referenced a code snip ...

  10. php gui中文手册,git gui - [ Git中文开发手册 ] - 在线原生手册 - php中文网

    名称 git-gui  -  Git 的便携式图形界面 概要 git gui [] [arguments] 描述 基于 Tcl / Tk 的 Git 图形用户界面.git gui侧重于允许用户通过新的 ...

最新文章

  1. 根据输入时间段备份压缩日志文件
  2. Mac OS 错误代码 -8072的可行解决方法
  3. 面试题18: 删除链表节点:删除链表中重复的节点
  4. TensorFlow学习笔记(十九) 基本算术运算和Reduction归约计算
  5. SpringBoot精选项目
  6. upload file to server
  7. Calendar的api方法
  8. python实用库_python常用库
  9. error: storage class specified for parameter问题-转
  10. Java8新特性(二)——强大的Stream API
  11. 服务器主板能插几块硬盘,如何知道自己的主板最大支持多少的硬盘啊
  12. 项目过程管理(五)需求文档
  13. Python—爬取全国城市名称案例(Xpath方法)
  14. 查找重复姓名的SQL语句
  15. 不开心就玩消消乐~~~正则表达式(1)
  16. [LTE] Inter-eNB S1 切换
  17. 树莓派——8、树莓派博通BCM2835芯片手册导读
  18. html鼠标悬停超链接(头像、文字)显示提示信息
  19. python语言编写爬虫_自写Python小爬虫一个 - 『编程语言区』 - 吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn...
  20. ros msg文件数组定义与使用

热门文章

  1. Tomcat底层原理
  2. Industrial Style Transfer with Large-scale Geometric Warping and Content Preservation论文解读
  3. cad解除块的快捷命令_47个快捷键50个CAD技巧,快收藏起来
  4. R软件和扩展包的升级及R语言数据对象
  5. 设计模式之UML画图
  6. 商城GW-SHOP,基于 微信小程序 + springboot + vue 技术构建
  7. Windows10安装Matlab 2018b教程
  8. Python写的一个文件生成器脚本
  9. 计算机在食品科学中的应用统计学,响应面法及其在食品中的应用
  10. Unity 根据文件路径批量修改图片格式