TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   PHPTal: unset variables (http://www.talkphp.com/general/3946-phptal-unset-variables.html)

nightowl 02-06-2009 03:33 PM

PHPTal: unset variables
 
When I design a template that refers to some var

e.g.

Code:

<span tal:content="title"></span>
If my PHP script doesn't set this var, an error is thrown by PHPTal.

Code:

Unable to find path title in current scope
I'd prefer if it just went on, rendering it with an empty value for that var.

Is that possible?

nightowl 03-05-2009 01:59 PM

Anybody who can help me with this?

Wildhoney 03-05-2009 06:31 PM

I don't know anything about PHPTal, but is it not possible to do something like the following to set a blank title variable?

php Code:
$this->view->title = $szTitle ? $szTitle : null;

nightowl 03-06-2009 11:22 AM

yes, that is possible. But I don't want to assign values to all possible vars in the template. There are numerous places where you want to foresee that you can add data, but often you don't actually want to do it for this particular page...

wtyqqqqqqqqqiru 04-05-2009 01:26 AM

Use tal:condition="exists:variablename" before using it.

See answer on stackoverflow: http://stackoverflow.com/questions/4...ined-variables


All times are GMT. The time now is 02:41 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0