default_template_handler_func example in docs not working
| From: | DC | Date: | Tue, 23 Nov 2004 17:51:32 +0000 |
| Subject: | default_template_handler_func example in docs not working | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11997@lists.php.net to get a copy of this message | ||
hi everyone.
when i try to use the default template handler function to write templates
on the fly...
(as suggested in the docs at:
http://smarty.php.net/manual/en/template.resources.php
), smarty tells me that _write_file() doesn't exist with error:
Fatal error: Call to undefined function: _write_file()
I copied the function:
function
make_template($resource_type,$resource_name,&$template_source,&$template_tim
estamp,&$smarty_obj){
if($resource_type=='file'){
if(!is_readable($resource_name)){
// create the template file, return contents.
$template_source = "This is a new template.";
$template_timestamp = time();
// there seems to be a problem with this write_file function
$smarty_obj->_write_file($resource_name,$template_source);
return true;
}
}else{
// not a file
return false;
}
}
I couldn't find the _write_file function anywhere in my smarty source code.
I am using version 2.5.0 so I wonder if that has anything to do with this
error. but, I checked the change log for anything that looked relevant and I
didn't see anywhere that _write_file had been renamed. I also checked the
core files and found other write_file functions, but none seemed easily
adaptable to this technique.
Any one using this technique and or this code? Is there an easy answer or
debug path I should follow?
Thx,
dan