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

Name

display (ausgeben)

void display(string template,
             string cache_id,
             string compile_id);

Gibt ein Template aus. Sie müssen einen gültigen Template Ressourcen-Typ inklusive Pfad angeben. Als optionalen zweiten Parameter können Sie eine 'cache_id' übergeben. Konsultieren Sie den Abschnitt über caching für weitere Informationen.

Als optionalen dritten Parameter können Sie eine 'compile_id' übergeben. Dies ist wertvoll, falls Sie verschiedene Versionen eines Templates kompilieren wollen - zum Beispiel in verschiedenen Sprachen. 'compile_id' wird auch verwendet, wenn Sie mehr als ein '$template_dir' aber nur ein '$compile_dir' haben. Setzen Sie dazu für jedes Verzeichnis eine eigene 'compile_id', andernfalls werden Templates mit dem gleichen Namen überschrieben. Sie können die Variable $compile_id auch einmalig setzen, anstatt sie bei jedem Aufruf von 'display()' zu übergeben.

Example 13.12. display (ausgeben)


<?php
include("Smarty.class.php");
$smarty = new Smarty;
$smarty->caching = true;

// Datenbank-Aufrufe nur durchf&uuml;hren, wenn kein Cache existiert
if(!$smarty->is_cached("index.tpl")) {

  // Beispieldaten
  $address = "245 N 50th";
  $db_data = array(
               "City" => "Lincoln",
               "State" => "Nebraska",
               "Zip" => "68502"
             );

  $smarty->assign("Name","Fred");
  $smarty->assign("Address",$address);
  $smarty->assign($db_data);

}

// ausgabe
$smarty->display("index.tpl");
?>


Verwenden Sie die Syntax von template resources um Dateien ausserhalb von '$template_dir' zu verwenden.

Example 13.13. Beispiele von Template-Ressourcen für 'display()'


<?php
// absoluter Dateipfad
$smarty->display("/usr/local/include/templates/header.tpl");

// absoluter Dateipfad (alternativ)
$smarty->display("file:/usr/local/include/templates/header.tpl");

// absoluter Dateipfad unter Windows (MUSS mit 'file:'-Prefix versehen werden)
$smarty->display("file:C:/www/pub/templates/header.tpl");

// aus der Template-Ressource 'db' einbinden
$smarty->display("db:header.tpl");
?>
     

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 3 plus 11? (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