<HTML ><HEAD ><TITLE >{fetch}</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Smarty Manual" HREF="index.html"><LINK REL="UP" TITLE="Custom Functions" HREF="language.custom.functions.html"><LINK REL="PREVIOUS" TITLE="{eval}" HREF="language.function.eval.html"><LINK REL="NEXT" TITLE="{html_checkboxes}" HREF="language.function.html.checkboxes.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Smarty Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="language.function.eval.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 8. Custom Functions</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.function.html.checkboxes.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.function.fetch" ></A >{fetch}</H1 ><P > <TT CLASS="varname" >{fetch}</TT > is used to retrieve files from the local file system, http, or ftp and display the contents. </P ><P ></P ><UL ><LI ><P > If the file name begins with <TT CLASS="parameter" ><I >http://</I ></TT >, the web site page will be fetched and displayed. <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > This will not support http redirects, be sure to include a trailing slash on your web page fetches where necessary. </P ></BLOCKQUOTE ></DIV > </P ></LI ><LI ><P > If the file name begins with <TT CLASS="parameter" ><I >ftp://</I ></TT >, the file will be downloaded from the ftp server and displayed. </P ></LI ><LI ><P > For local files, either a full system file path must be given, or a path relative to the executed php script. <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > If template <A HREF="variable.security.html" > <TT CLASS="parameter" ><I >$security</I ></TT ></A > is enabled and you are fetching a file from the local file system, <TT CLASS="varname" >{fetch}</TT > will only allow files from within one of the defined <A HREF="variable.secure.dir.html" >secure directories</A >. </P ></BLOCKQUOTE ></DIV > </P ></LI ><LI ><P > If the <TT CLASS="parameter" ><I >assign</I ></TT > attribute is set, the output of the <TT CLASS="varname" >{fetch}</TT > function will be assigned to this template variable instead of being output to the template. </P ></LI ></UL ><DIV CLASS="informaltable" ><A NAME="AEN3031" ></A ><P ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >Attribute Name</TH ><TH WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >Type</TH ><TH WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >Required</TH ><TH WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >Default</TH ><TH WIDTH="20%" ALIGN="LEFT" VALIGN="MIDDLE" >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >file</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >string</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >Yes</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" ><SPAN CLASS="emphasis" ><I CLASS="emphasis" >n/a</I ></SPAN ></TD ><TD WIDTH="20%" ALIGN="LEFT" VALIGN="MIDDLE" >The file, http or ftp site to fetch</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >assign</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >string</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" >No</TD ><TD WIDTH="20%" ALIGN="CENTER" VALIGN="MIDDLE" ><SPAN CLASS="emphasis" ><I CLASS="emphasis" >n/a</I ></SPAN ></TD ><TD WIDTH="20%" ALIGN="LEFT" VALIGN="MIDDLE" >The template variable the output will be assigned to</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN3060" ></A ><P ><B >Example 8-8. {fetch} examples</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >{* include some javascript in your template *} {fetch file='/export/httpd/www.example.com/docs/navbar.js'} {* 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'} {* as above but with variables *} {fetch file="ftp://`$user`:`$password`@`$server`/`$path`"} {* assign the fetched contents to a template variable *} {fetch file='http://www.myweather.com/68502/' assign='weather'} {if $weather ne ''} <div id="weather">{$weather}</div> {/if}</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE ><P > See also <A HREF="language.builtin.functions.html#language.function.capture" ><TT CLASS="varname" >{capture}</TT ></A >, <A HREF="language.function.eval.html" ><TT CLASS="varname" >{eval}</TT ></A >, <A HREF="language.custom.functions.html#language.function.assign" ><TT CLASS="varname" >{assign}</TT ></A > and <A HREF="api.fetch.html" ><TT CLASS="varname" >fetch()</TT ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="language.function.eval.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.function.html.checkboxes.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >{eval}</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="language.custom.functions.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >{html_checkboxes}</TD ></TR ></TABLE ></DIV ></BODY ></HTML >