Get Smarty

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:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

fetch

Nome Attributo Tipo Obbligatorio Default Descrizione
file stringa nessuno il file o l'indirizzo http o ftp da caricare
assign stringa no nessuno la variabile del template cui assegnare l'output

fetch si usa per recuperare file dal filesystem locale, oppure da un indirizzo http o ftp, e visualizzarne il contenuto. Se il nome del file inizia per "http://", la pagina web verrà letta e visualizzata. Se il nome del file inizia per "ftp://", il file verrà recuperato dal server ftp e visualizzato. Per i file locali deve essere indicato l'intero percorso sul filesystem oppure un percorso relativo all'indirizzo dello script php in esecuzione.

Se fornite lo speciale attributo "assign", l'output della funzione fetch verrà assegnato a questa variabile invece di essere stampato in output. (novità di Smarty 1.5.0)

Nota tecnica

I redirect http non sono supportati, quindi assicuratevi di mettere lo slash finale sull'indirizzo della pagina web quando necessario.

Nota tecnica

Se è attivata la security del template e state cercando di caricare un file dal filesystem locale, saranno consentiti soltanto file compresi in una delle directory definite sicure ($secure_dir).

Example 8.5. fetch


{* inclusione di un javascript nel template *}
{fetch file="/export/httpd/www.example.com/docs/navbar.js"}

{* incorporazione nel template del testo relativo al tempo proveniente da un altro sito *}
{fetch file="http://www.myweather.com/68502/"}

{* lettura via ftp dei titoli delle ultime notizie *}
{fetch file="ftp://user:password@ftp.example.com/path/to/currentheadlines.txt"}

{* assegnazione del contenuto letto ad una variabile del template *}
{fetch file="http://www.myweather.com/68502/" assign="weather"}
{if $weather ne ""}
	<b>{$weather}</b>
{/if}

  

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 10 plus 0? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com
ASP.NET hosting @aspnethosting.co.uk