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

display()

display() -- menampilkan template

Deskripsi

void display ( string template [, string cache_id [, string compile_id]])

Ini menampilkan template tidak seperti fetch(). Sertakan tipe dan path sumber daya template yang benar. Sebagai parameter opsional kedua, anda bisa mengirimkan $cache id, lihat seksi caching untuk informasi lebih jauh.

Sebagai parameter opsional ketiga, anda dapat mengoper $compile_id. Ini dalam keadaan di mana anda ingin mengompilasi versi berbeda terhadap template yang sama, seperti memiliki template terpisa dikompilasi untuk bahasa yang berbeda. Penggunaan lainnya untuk $compile_id ialah saat anda menggunakan lebih dari satu $template_dir tapi hanya satu $compile_dir. Set $compile_id secara terpisah untuk setiap $template_dir, atau sebaliknya template dengan nama sama akan saling menimpa. Anda juga bisa menyetel variabel $compile_id sekali daripada mengoperkan ini ke setiap pemanggilan fungsi ini.

Teladan 13-1. display()

caching = true; // hanya melakukan panggilan db jika cache tidak ada if(!$smarty->is_cached(\'index.tpl\')) { // buat dummy untuk beberapa data $address = \'245 N 50th\'; $db_data = array( \'City\' => \'Lincoln\', \'State\' => \'Nebraska\', \'Zip\' => \'68502\' ); $smarty->assign(\'Name\', \'Fred\'); $smarty->assign(\'Address\', $address); $smarty->assign(\'data\', $db_data); } // tampilkan output $smarty->display(\'index.tpl\'); ?>'); ?>

Teladan 13-2. Contoh sumber data lain dari display()

Gunakan sintaks sumber daya template untuk menampilkan file di luar $template_dir direktori.

display(\'/usr/local/include/templates/header.tpl\'); // path file absolut (hal yang sama) $smarty->display(\'file:/usr/local/include/templates/header.tpl\'); // path file absolut windows (HARUS memakai prefiks "file:") $smarty->display(\'file:C:/www/pub/templates/header.tpl\'); // sertakan dari sumber daya template bernama "db" $smarty->display(\'db:header.tpl\'); ?>'); ?>

Lihat juga fetch() dan template_exists().

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 0 plus 19? (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