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

Chapter 7. Eingebaute Funktionen

Smarty enthält eine Reihe eingebauter Funktionen. Eingebaute Funktionen sind integral für die Template-Sprache. Sie können sie weder verändern noch eigene Funktionen unter selbem Namen erstellen.

{capture} (Ausgabe abfangen)

{capture} wird verwendet, um die Template-Ausgabe abzufangen und in einer Variable zu speichern. Der Inhalt zwischen {capture name="foo"} und {/capture} wird unter der im 'name' Attribut angegebenen Capture-Variablen abgelegt und kann über $smarty.capture.foo angesprochen werden. Falls kein 'name'-Attribut übergeben wurde, wird der Inhalt in 'default' (also $smarty.capture.default) abgelegt. Jede {capture} Sektion muss mit {/capture} beendet werden. {capture}-Blöcke können verschachtelt sein.

Attribut Name Typ Benötigt Standardwert Beschreibung
name string no default Der Name des abgefangenen Blocks
assign string No n/a Der Name der Variable welcher der Wert zugewiesen werden soll.

Caution

Seien Sie vorsichtig, wenn sie die Ausgabe von {insert} abfangen wollen. Sie sollten die Ausgabe nicht abfangen, wenn Caching eingeschaltet ist und Sie einen {insert} Befehl verwenden, um Ausgaben vom Caching auszuschliessen.

Example 7.1. Template-Inhalte abfangen



{* Tabellenzeile nur ausgeben, wenn Inhalt vorhanden *}
{capture name=banner}
{include file='get_banner.tpl'}
{/capture}
{if $smarty.capture.banner ne ""}
<table>
<tr>
  <td>
    {$smarty.capture.banner}
  </td>
</tr>
</table>
{/if}

   


Example 7.2. Template-Inhalte abfangen

Hier ist ein Beispiel das das Zusammenspiel mit der Funktion {popup} demonstriert.


  {capture name=some_content assign=popText}
    .... some content ....
  {/capture}
  
  <a href="#" {popup caption='Help' text=$popText}>help</a>

   


Siehe auch: $smarty.capture, {eval}, {fetch}, fetch() and {assign}.

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