{fetch}

{fetch} is used to retrieve files from the local file system, http, or ftp and display the contents.

Attribute NameTypeRequiredDefaultDescription
filestringYesn/aThe file, http or ftp site to fetch
assignstringNon/aThe template variable the output will be assigned to

Example 8-8. {fetch} examples

{* 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}

See also {capture}, {eval}, {assign} and fetch().