Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Largest classified with thousands of ads at Shoppok

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Find Wedding Dresses Online at Canada from Ca-dresses.com

Find your local domestic cleaner

Read these great ice cream maker reviews

Brautkleider auf Topwedding.de

Best Wedding Dresses Australia at AuBridalDresses.com

Find free files to download on allwhatyouwant.net

Advertisement

{fetch}

{fetch} is used to retrieve 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.

    Note

    This will not support http redirects, be sure to include a trailing slash on your web page fetches where necessary.

  • If the file name begins with ftp://, the file will be downloaded from the ftp server and displayed.

  • For local files, either a full system file path must be given, or a path relative to the executed php script.

    Note

    If template $security is enabled and you are fetching a file from the local file system, {fetch} will only allow files from within one of the defined secure directories.

  • If the assign attribute is set, the output of the {fetch} function will be assigned to this template variable instead of being output to the template.

Attribute Name Type Required Default Description
file string Yes n/a The file, http or ftp site to fetch
assign string No n/a The 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().

Comments
by moroz1999 on Nov 8, 2011 at 7:53
Using a path, relative to a current template would make much more sense, imho.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 14 plus 19? (Are you human?)

Advertisement

Sponsors [info]

UK Web Hosting @webhost.uk.net
Best Web Hosting @rshosting.com
Web Hosting UK @webhostinguk.com
Unlimited Web Hosting @infrenion.com
App Entwicklung @morphodo.com
GoDaddy Coupon @buy-hosting.net
First Click Internet Marketing @fcinternetmarketing.com