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

fetch

string fetch(string template,
             string cache_id,
             string compile_id);

Gibt die Ausgabe des Template zurück, anstatt es direkt anzuzeigen. Übergeben Sie einen gültigen Template Ressource-Typ und -Pfad. Als optionaler zweiter Parameter kann eine 'cache_id' übergeben werden. Bitte 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 dann 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 'fetch()' zu übergeben.

Example 13.14. fetch


<?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 abfangen
$output = $smarty->fetch("index.tpl");

// Etwas mit $output anstellen

echo $output;
?>


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 17 plus 2? (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