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}

{fetch} は、ローカルシステムやhttp, ftpからファイルを取得し、 コンテンツを表示します。

  • ファイル名が http:// から始まる場合は、web サイト上のページを取得して表示します。

    Note

    http リダイレクトはサポートしていません。 必要に応じて、最後のスラッシュをつけることを忘れないようにしましょう。

  • ファイル名が ftp:// で始まる場合は、 ftp サーバからダウンロードしたファイルを表示します。

  • ローカルファイルの場合には、ファイルのフルパスあるいは 実行する PHP スクリプトからの相対パスを指定する必要があります。

    Note

    テンプレートの $security が有効になっており、 ファイルをローカルファイルシステムから取得する場合、 {fetch} は定義済みの 安全なディレクトリ のいずれかにあるファイルのみを受け付けます。

  • assign 属性を指定すると、 {fetch} 関数の出力がこのテンプレート変数に割り当てられます。 テンプレートには出力されません。

属性名 必須 デフォルト 概要
file string Yes n/a 取得するファイル、http あるいは ftp のサイト
assign string No n/a 出力が割り当てられるテンプレート変数

Example 8.8. {fetch} の例


{* テンプレートにJavaScriptを含めます *}
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}

{* 他のwebサイトからテンプレートに天候のテキストを埋め込みます *}
{fetch file='http://www.myweather.com/68502/'}

{* ftp経由でニュースヘッドラインファイルを取得します *}
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
{* 上と同じですが、変数を使用します *}
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}

{* 取得したコンテンツをテンプレート変数に割り当てます *}
{fetch file='http://www.myweather.com/68502/' assign='weather'}
{if $weather ne ''}
  <div id="weather">{$weather}</div>
{/if}

  

{capture}{eval}{assign} および fetch() も参照してください。

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 18 plus 3? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
Cheap Hosting @HostsVault
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