Deskripsi
bool
template_exists ( string template)
Ini dapat menerima baik path ke template pada sistem file ataupun string
sumber daya yang menetapkan template.
Teladan 13-1. template_exists()
Contoh ini menggunakan $_GET['page'] untuk
{include}
konten template. Jika template tidak ada maka halaman kesalahan yang
ditampilkan. Pertama page_container.tpl
<html> <head><title>{$title}</title></head> <body> {include file='page_top.tpl'}
{* sertakan halaman konten tengah *} {include file=$content_template}
{include file='page_footer.tpl'} </body>
|
Dan naskah php
<?php
// set nama file, contoh index.inc.tpl $mid_template = $_GET['page'].'.inc.tpl';
if( !$smarty->template_exists($mid_template) ){ $mid_template = 'page_not_found.tpl'; } $smarty->assign('content_template', $mid_template);
$smarty->display('page_container.tpl');
?>
|
|
Lihat juga
display(),
fetch(),
{include}
and
{insert}