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} (Konfiguration laden)

Diese Funktion wird verwendet, um Variablen aus einer Konfigurationsdatei in das Template zu laden. Sehen sie Config Files (Konfigurationsdateien) für weitere Informationen.

Attribut Name Typ Erforderlich Standardwert Beschreibung
file string Ja n/a Definiert den Namen der einzubindenden Datei.
section string Nein n/a Definiert den Namen des zu ladenden Abschnitts.
scope string Nein local Definiert den Geltungsbereich der zu ladenden Variablen. Erlaubte Werte sind 'local','parent' und 'global'. 'local' bedeutet, dass die Variablen in den Context des lokalen Template geladen werden. 'parent' bedeutet, dass die Variablen sowohl in den lokalen Context, als auch in den Context des aufrufenden Templates eingebunden werden. 'global' bedeutet, dass die Variablen von allen Templates zugänglich sind.
global boolean Nein No Definiert, ob die Variablen von allen Templates aus zugänglich sind. WICHTIG: Dieses Attribut wird von 'scope' abgelöst und sollte nicht mehr verwendet werden. Falls 'scope' übergeben wurde, wird 'global' ignoriert.

Example 7.3. Funktion {config_load}

beispiel.conf


#Dies ist ein Konfigurationsdateikommentar

# globale Variablen
seitenTitel = "Hauptmenü"
bodyHintergrundFarbe = #000000
tabelleHintergrundFarbe = #000000
reiheHintergrundFarbe = #00ff00

# Kundenvariablen
[Kunden]
seitenTitel = "Kundeninfo"

  

and the template


{config_load file='example.conf'}

<html>
<title>{#seitenTitel#}</title>
<body bgcolor="{#bodyHintergrundFarbe#}">
<table border="{#tabelleRahmenBreite#}" bgcolor="{#tabelleHintergrundFarbe#}">
  <tr bgcolor="{#reiheHintergrundFarbe#}">
    <td>Vornamen</td>
    <td>Nachnamen</td>
    <td>Adresse</td>
  </tr>
</table>
</body>
</html>

  

Konfigurationsdateien können Abschnitte enthalten. Um Variablen aus einem Abschnitt zu laden, können Sie das Attribut section übergeben.

Bemerkung: Konfigurationdatei-Abschnitte (sections) und die eingebaute Template Funktion namens section haben ausser dem Namen nichts gemeinsam.

Example 7.4. Funktion {config_load} mit Abschnitten


{config_load file="beispiel.conf" section="Kunde"}
<html>
<title>{#seitenTitel#}</title>
<body bgcolor="{#bodyHintergrundFarbe#}">
<table border="{#tabelleRahmenBreite#}" bgcolor="{#tabelleHintergrundFarbe#}">
  <tr bgcolor="{#reiheHintergrundFarbe#}">
    <td>Vornamen</td>
    <td>Nachnamen</td>
    <td>Adresse</td>
  </tr>
</table>
</body>
</html>

  

Siehe $config_overwrite bezüglich Arrays von Konfigurationsvariablen.

Siehe auch Konfigurationsdateien, Variablen aus Konfigurationsdateien, $config_dir, get_config_vars() und 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 12 plus 15? (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