value of a variable can't be '0'
Brought to you by:
nhruby,
richardarcher
I got a template variable FILE_NB which can be equal to the string 0
.
But template function evaluate 0 as null and so gives me an error:
<b>Template Error:</b> loadfile: FILE_NB is not a valid handle.<br>
Test with this script to see the problem:
require 'template.inc';
$t = new template('/tmp');
//no matter what page.tpl contains
$t->set_file('page','page.tpl');
$t->set_var('FILE_NB','0');
$t->parse('out',array('FILE_NB','page'));
Suggested modification:
on the first line of the loadfile function, replace the test:
!empty($this->varvals[$handle])
with
strlen($this->varvals[$handle])
Logged In: YES
user_id=77269
The error says that FILE_NB is not a valid handle. Try this
instead:
$t->parse('out','page');
parse syntax:
parse($target, $varname, $append = false)
where $varname is defined in set_file for your example as
'page'.
set_file($varname, $filename = "")
See documentation:
http://www.sanisoft.com/phplib/manual/templateMethods.php#templateMethodsInt
0 is substitiuted into templates many many times.
hth,
Joe