update example to not be too misleading with unnecessarily detailed example code

This commit is contained in:
monte.ohrt
2009-02-25 20:09:09 +00:00
parent 438e1f983e
commit 22ffa6944c

View File

@@ -134,32 +134,20 @@ $smarty->display('file:F:/path/to/my/templates/menu.tpl');
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
{ {
// do database call here to fetch your template, // do database call here to fetch your template,
// populating $tpl_source // populating $tpl_source with actual template contents
$sql = new SQL; $tpl_source = "This is the template text";
$sql->query("select tpl_source // return true on success, false to generate failure notification
from my_table return true;
where tpl_name='$tpl_name'");
if ($sql->num_rows) {
$tpl_source = $sql->record['tpl_source'];
return true;
} else {
return false;
}
} }
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{ {
// do database call here to populate $tpl_timestamp. // do database call here to populate $tpl_timestamp
$sql = new SQL; // with unix epoch time value of last template modification.
$sql->query("select tpl_timestamp // This is used to determine if recompile is necessary.
from my_table $tpl_timestamp = time(); // this example will always recompile!
where tpl_name='$tpl_name'"); // return true on success, false to generate failure notification
if ($sql->num_rows) { return true;
$tpl_timestamp = $sql->record['tpl_timestamp'];
return true;
} else {
return false;
}
} }
function db_get_secure($tpl_name, &$smarty_obj) function db_get_secure($tpl_name, &$smarty_obj)