This commit is contained in:
pete_morgan
2006-03-13 22:48:14 +00:00
parent 1a65f0c0c3
commit c88dce0fd1

View File

@@ -13,7 +13,7 @@
<para> <para>
If you supply the special "assign" attribute, the output of the If you supply the special "assign" attribute, the output of the
{fetch} function will be assigned to this template variable instead of {fetch} function will be assigned to this template variable instead of
being output to the template. (new in Smarty 1.5.0) being output to the template.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
@@ -62,29 +62,32 @@
<note> <note>
<title>Technical Note</title> <title>Technical Note</title>
<para> <para>
If template security is turned on and you are If template <link linkend="variable.security">$security</link>
fetching a file from the local file system, this will only allow is turned on and you are
files from within one of the defined secure directories. fetching a file from the local file system, {fetch} will only allow
(<link linkend="variable.secure.dir">$secure_dir</link>) files from within one of the defined
<link linkend="variable.secure.dir">secure directories</link>.
</para> </para>
</note> </note>
<example> <example>
<title>fetch</title> <title>{fetch} examples</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* include some javascript in your template *} {* include some javascript in your template *}
{fetch file="/export/httpd/www.example.com/docs/navbar.js"} {fetch file='/export/httpd/www.example.com/docs/navbar.js'}
{* embed some weather text in your template from another web site *} {* embed some weather text in your template from another web site *}
{fetch file="http://www.myweather.com/68502/"} {fetch file='http://www.myweather.com/68502/'}
{* fetch a news headline file via ftp *} {* fetch a news headline file via ftp *}
{fetch file="ftp://user:password@ftp.example.com/path/to/currentheadlines.txt"} {fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
{* as above but with variables *}
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}
{* assign the fetched contents to a template variable *} {* assign the fetched contents to a template variable *}
{fetch file="http://www.myweather.com/68502/" assign="weather"} {fetch file='http://www.myweather.com/68502/' assign='weather'}
{if $weather ne ""} {if $weather ne ''}
<b>{$weather}</b> <div id="weather">{$weather}</div>
{/if} {/if}
]]> ]]>
</programlisting> </programlisting>
@@ -92,7 +95,8 @@
<para> <para>
See also See also
<link linkend="language.function.capture">{capture}</link>, <link linkend="language.function.capture">{capture}</link>,
<link linkend="language.function.eval">{eval}</link> <link linkend="language.function.eval">{eval}</link>,
<link linkend="language.function.assign">{assign}</link>
and and
<link linkend="api.fetch">fetch()</link>. <link linkend="api.fetch">fetch()</link>.
</para> </para>