mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
update docs for fetching only timestamp with custom template source functions
This commit is contained in:
@@ -1225,7 +1225,7 @@ function _run_mod_handler()
|
||||
{
|
||||
$results = $this->_read_file($cache_file);
|
||||
|
||||
// get the templates involved with this cache from the first line
|
||||
// get the files involved with this cache from the first line
|
||||
$contents = explode("\n", $results, 2);
|
||||
|
||||
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
|
||||
|
23
docs.sgml
23
docs.sgml
@@ -1386,10 +1386,15 @@ $smarty->display("file:/path/to/my/templates/menu.tpl");
|
||||
retrieving templates from a database. You do this by first
|
||||
registering your resource handler function, then creating your
|
||||
function to get the template. Smarty expects your function to be of
|
||||
this form: funcname($tpl_name,&$tpl_source, &$tpl_timestamp)
|
||||
{} $tpl_name is passed into the function, and your function should
|
||||
populate $tpl_source and $tpl_timestamp with the template source
|
||||
and the last modified time of the template respectively.
|
||||
this form: funcname($tpl_name,&$tpl_source,
|
||||
&$tpl_timestamp[, boolean]) {} $tpl_name is passed into the
|
||||
function, and your function should populate $tpl_source and
|
||||
$tpl_timestamp with the template source and the last modified time
|
||||
of the template respectively. The fourth parameter is a boolean
|
||||
value, used for determining if the source should be returned or
|
||||
not. Default this value to true in your function. If false gets
|
||||
passed, you only need to return the timestamp parameter. This was
|
||||
added to Smarty 1.4.6.
|
||||
</para>
|
||||
<example>
|
||||
|
||||
@@ -1399,12 +1404,18 @@ $smarty->display("file:/path/to/my/templates/menu.tpl");
|
||||
// from PHP script
|
||||
|
||||
// put this function somewhere in your application
|
||||
function get_db_template ($tpl_name, &$tpl_source, &$tpl_timestamp) {
|
||||
function get_db_template ($tpl_name, &$tpl_source, &$tpl_timestamp,
|
||||
$get_source=true) {
|
||||
|
||||
if($get_source) {
|
||||
// do database calls (or whatever) here to fetch your template, populating
|
||||
// $tpl_source and $tpl_timestamp.
|
||||
|
||||
$tpl_source = "This is a simulation of a template fetched from a db.";
|
||||
$tpl_timestamp = mktime();
|
||||
} else {
|
||||
// just populate $tpl_timestamp.
|
||||
$tpl_timestamp = mktime();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1225,7 +1225,7 @@ function _run_mod_handler()
|
||||
{
|
||||
$results = $this->_read_file($cache_file);
|
||||
|
||||
// get the templates involved with this cache from the first line
|
||||
// get the files involved with this cache from the first line
|
||||
$contents = explode("\n", $results, 2);
|
||||
|
||||
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
|
||||
|
Reference in New Issue
Block a user