Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

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:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Name

fetch() 鈥 鍙栧緱杈撳嚭鍐呭

璇存槑

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

璇ュ嚱鏁板皢鍙栧緱涓涓ā鏉胯緭鍑虹殑鍐呭锛岃屼笉鏄鏄剧ず鍑烘潵銆 璇ュ嚱鏁伴渶瑕佹寚瀹氫竴涓悎娉曠殑妯℃澘璧勬簮鐨勭被鍨嬪拰璺緞銆 绗簩涓彲閫夌殑鍙傛暟$cache_id璁剧疆缂撳瓨锛岃鎯呭弬瑙 缂撳瓨

As an optional third parameter, you can pass a $compile_id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled for different languages. You can also set the $compile_id variable once instead of passing this to each call to this function.

Example聽14.21.聽fetch()


<?php
include('Smarty.class.php');
$smarty = new Smarty;

$smarty->setCaching(true);

// 鎸夌収URL鏉D5鐢熸垚涓涓壒瀹氱殑缂撳瓨ID
$cache_id = md5($_SERVER['REQUEST_URI']);

// 鎹曡幏杈撳嚭
$output = $smarty->fetch('index.tpl', $cache_id);

// 澶勭悊杈撳嚭鐨勫唴瀹
echo $output;
?>

    


Example聽14.22.聽鐢╢etch()鏉ュ彂閭欢

email_body.tpl妯℃澘鐨勫唴瀹癸細


Dear {$contact_info.name},

Welcome and thank you for signing up as a member of our user group.

Click on the link below to login with your user name
of '{$contact_info.username}' so you can post in our forums.

{$login_url}

List master

{textformat wrap=40}
This is some long-winded disclaimer text that would automatically get wrapped
at 40 characters. This helps make the text easier to read in mail programs that
do not wrap sentences for you.
{/textformat}

    

璇HP鑴氭湰浣跨敤浜哖HP鐨 mail()鍑芥暟銆


<?php

// 浠庢暟鎹簱鎴栧叾浠栨潵婧愯幏鍙栧埌$contact_info

$smarty->assign('contact_info',$contact_info);
$smarty->assign('login_url',"http://{$_SERVER['SERVER_NAME']}/login");

mail($contact_info['email'], 'Thank You', $smarty->fetch('email_body.tpl'));

?>

    


鍙傝 {fetch} display(), {eval}, 鍜 templateExists().

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 10 plus 3? (Are you human?)

Advertisement