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

Variablen

Templatevariablennamen beginnen mit einem $dollar-Zeichen. Sie können Ziffer, Buchstaben und Unterstriche ('_') enthalten, sehr ähnlich den Variablen in PHP. Numerische Arrayindizes können referenziert werden und auch Nichtnumerische. Zugriff auf Objekteigenschaften und -methoden ist auch möglich. Konfigurationsvariablen sind einer Ausname was die Dollarzeichen-Syntax angeht. Diese werden durch umgebende #Doppelkreuze# oder über die Varible $smarty.config referenziert.

Example 3.2. Variablen


{$foo}        <-- Zeigt einfache Variable an (kein Array oder Objekt)
{$foo[4]}     <-- Zeigt 5. Element von einem Array an, deren Schlussel bei 0 beginnen
{$foo.bar}    <-- Zeigt das Element zum Schlüssel "bar" des Arrays an (wie PHPs $foo['bar'])
{$foo.$bar}   <-- Zeigt das Element eines variablen Schlüssels an (wie PHPs $foo[$bar])
{$foo->bar}   <-- Zeigt eine Eigenschaft "bar" des Objekts $foo an
{$foo->bar()} <-- Zeigt den Rückgabewert der Objectmethode "bar" an
{#foo#}       <-- Zeift die Konfigurationsvariable "foo" an
{$smarty.config.foo} <-- Synonym für {#foo#}
{$foo[bar]}   <-- Syntax zum zugriff auf Element in einer Section-Schleife, siehe {section}
{assign var=foo value="baa"}{$foo} <--  Gibt "baa" aus, siehe {assign}

Viele weitere Kombinationen sind erlaubt

{$foo.bar.baz}
{$foo.$bar.$baz}
{$foo[4].baz}
{$foo[4].$baz}
{$foo.bar.baz[4]}
{$foo->bar($baz,2,$bar)} <-- Parameter übergeben
{"foo"}       <-- Statische (konstante) Werte sind auch erlaubt

  

Siehe auch: Die reservierte {$smarty} Variable und Verwendung von Variablen aus Konfigurationsdateien.

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
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