helmut2509 Posted August 9, 2018 Posted August 9, 2018 Hello, I just found out that, when passing a (numeric) zero with "$view->myVar=0" to a template then the corresponding template variable $this->myVar is empty, it has no value. This even occurs when I convert the value to a string: (string) 0 Strings and numeric values other than zero are handled correctly. I think this is a bug which should be fixed?! regards, Helmut
cstevensjr Posted August 9, 2018 Posted August 9, 2018 11 minutes ago, helmut2509 said: Hello, I just found out that, when passing a (numeric) zero with "$view->myVar=0" to a template then the corresponding template variable $this->myVar is empty, it has no value. This even occurs when I convert the value to a string: (string) 0 Strings and numeric values other than zero are handled correctly. I think this is a bug which should be fixed?! regards, Helmut Please open an issue at: https://github.com/processwire/processwire-issues
dragan Posted August 9, 2018 Posted August 9, 2018 1 hour ago, helmut2509 said: when passing a (numeric) zero with "$view->myVar=0" to a template you pass it via API to a template or a page? In case of the latter, I can't reproduce that.
Robin S Posted August 9, 2018 Posted August 9, 2018 5 hours ago, helmut2509 said: I just found out that, when passing a (numeric) zero with "$view->myVar=0" to a template What is $view? The PW core does not have the concept of a view that variables are passed to - there are just template files where the API variables are available. I think this is not a core issue but perhaps you are using some third-party templating module in which case you should raise this in the module's support thread.
Soma Posted August 10, 2018 Posted August 10, 2018 Assuming you use TemplateFile ? This works as it should, variables are passed as is: $tpl = new TemplateFile("_tpl.php"); $tpl->myVar1 = 0; $tpl->set("myVar2", 1); $content .= $tpl->render(); in _tpl.php echo $myVar1; echo $myVar2; Outputs: 01
helmut2509 Posted August 10, 2018 Author Posted August 10, 2018 17 hours ago, Robin S said: What is $view? The PW core does not have the concept of a view that variables are passed to - there are just template files where the API variables are available. I think this is not a core issue but perhaps you are using some third-party templating module in which case you should raise this in the module's support thread. 21 hours ago, dragan said: you pass it via API to a template or a page? In case of the latter, I can't reproduce that. $view is an instance of \ProcessWire\TemplateFile
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now