{fetch}

    {fetch}用来从当地文件系统,HTTP或者FTP中获取文件并显示其内容。

属性名 类型 必需? 缺省 描述
filestringYesn/a 需要获得的文件,HTTP或FTP地址
assignstringNon/a 输出将赋予的变量名

例子8-8. {fetch}

{* 在模板中包含一些JavaScript *}
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}

{* 从另一个站点包含一些气象信息 *}
{fetch file='http://www.myweather.com/68502/'}

{* 通过FTP获得新闻标题 *}
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
{* 同上,但通过变量实现 *}
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}

{* 将获取的内容赋予一个模板变量 *}
{fetch file='http://www.myweather.com/68502/' assign='weather'}
{if $weather ne ''}
  <div id="weather">{$weather}</div>
{/if}

    参见{capture}{eval}{assign}以及fetch()