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

{config_load}

{config_load} dipakai untuk mengambil #variables# konfig dari file konfigurasi ke dalam template.

Attribute NameTypeRequiredDefaultDescription
filestringYesn/aNama file config untuk disertakan
sectionstringNon/aNama seksi untuk diambil
scopestringnolokal Bagaimana lingkup variabel yang diambil diperlakukan, yang harus berupa lokal, parent atau global. Lokal berarti variabel diambil ke dalam konteks template lokal. parent berarti variabel diambil ke dalam konteks lokal dan template leluhur yang memanggilnya. global berarti variabel tersedia bagi seluruh template.
globalbooleanNoNo Apakah variabel terlihat ke template leluhurnya atau tidak, sama seperti scope=parent. CATATAN: Atribut ini tidak dipakai lagi oleh atribut scope, tapi masih didukugn. Jika scope disertakan, nilai ini diabaikan.

Teladan 7-3. {config_load}

File example.conf.

#ini komentar file config

# variabel global
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00

#seksi variabel kustomer
[Customer]
pageTitle = "Customer Info"

dan template

{config_load file="example.conf"}

<html>
<title>{#pageTitle#|default:"No title"}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
   <tr bgcolor="{#rowBgColor#}">
      <td>First</td>
      <td>Last</td>
      <td>Address</td>
   </tr>
</table>
</body>
</html>

File Config dapat juga berisi seksi. Anda bisa mengambil variabel dari dalam seksi dengan menambahkan atribut section. Catatan bahwa variabel config global selalu diambil bersamaan dengan variabel seksi, dan variabel seksi bernama-sama menimpa global.

Catatan: Seksi file config dan fungsi template built-in memanggil {section} tidak ada kaitannya dengan yang lain, itu terjadi untuk berbagi konvensi penamaan umum.

Teladan 7-4. function {config_load} dengan seksi

{config_load file='example.conf' section='Customer'}

<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
   <tr bgcolor="{#rowBgColor#}">
      <td>First</td>
      <td>Last</td>
      <td>Address</td>
   </tr>
</table>
</body>
</html>

Lihat $config_overwrite untuk membuat arrays dari variabel file config.

Lihat juga halaman config files, halaman config variables, $config_dir, get_config_vars() dan config_load().

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 5 plus 13? (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