Files
smarty/docs/en/designers/language-custom-functions/language-function-fetch.xml

120 lines
3.4 KiB
XML
Raw Normal View History

2004-04-13 08:46:28 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2004-05-29 21:56:21 +00:00
<sect1 id="language.function.fetch">
<title>{fetch}</title>
2005-09-13 19:03:11 +00:00
<para>
{fetch} is used to fetch files from the local file system, http, or
ftp and display the contents. If the file name begins with
"http://", the web site page will be fetched and displayed. If the
file name begins with "ftp://", the file will be fetched from the
ftp server and displayed. For local files, the full system file
path must be given, or a path relative to the executed php script.
</para>
<para>
If you supply the special "assign" attribute, the output of the
{fetch} function will be assigned to this template variable instead of
being output to the template. (new in Smarty 1.5.0)
</para>
2004-05-29 21:56:21 +00:00
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
<colspec colname="type" align="center" />
<colspec colname="required" align="center" />
<colspec colname="default" align="center" />
<colspec colname="desc" />
<thead>
<row>
<entry>Attribute Name</entry>
<entry>Type</entry>
<entry>Required</entry>
<entry>Default</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>file</entry>
<entry>string</entry>
<entry>Yes</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>the file, http or ftp site to fetch</entry>
</row>
<row>
<entry>assign</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>the template variable the output will be assigned
to</entry>
</row>
</tbody>
</tgroup>
</informaltable>
2005-09-13 19:03:11 +00:00
2004-05-29 21:56:21 +00:00
<note>
<title>Technical Note</title>
<para>
This will not support http redirects, be sure to
include a trailing slash on your web page fetches where necessary.
</para>
</note>
<note>
<title>Technical Note</title>
<para>
If template security is turned on and you are
fetching a file from the local file system, this will only allow
files from within one of the defined secure directories.
(<link linkend="variable.secure.dir">$secure_dir</link>)
2004-05-29 21:56:21 +00:00
</para>
</note>
<example>
<title>fetch</title>
<programlisting>
<![CDATA[
2004-04-13 08:46:28 +00:00
{* include some javascript in your template *}
{fetch file="/export/httpd/www.example.com/docs/navbar.js"}
2004-04-13 08:46:28 +00:00
{* embed some weather text in your template from another web site *}
{fetch file="http://www.myweather.com/68502/"}
{* fetch a news headline file via ftp *}
{fetch file="ftp://user:password@ftp.example.com/path/to/currentheadlines.txt"}
2004-04-13 08:46:28 +00:00
{* assign the fetched contents to a template variable *}
{fetch file="http://www.myweather.com/68502/" assign="weather"}
{if $weather ne ""}
<b>{$weather}</b>
2004-05-29 21:56:21 +00:00
{/if}
2004-05-29 22:01:12 +00:00
]]>
2004-05-29 21:56:21 +00:00
</programlisting>
</example>
<para>
See also
<link linkend="language.function.capture">{capture}</link>,
<link linkend="language.function.eval">{eval}</link>
and
<link linkend="api.fetch">fetch()</link>.
</para>
2004-04-13 08:46:28 +00:00
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->