TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-06-2009, 03:33 PM   #1 (permalink)
The Wanderer
 
Join Date: Jan 2009
Posts: 8
Thanks: 1
nightowl is on a distinguished road
Default 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 is offline  
Reply With Quote
Old 03-05-2009, 01:59 PM   #2 (permalink)
The Wanderer
 
Join Date: Jan 2009
Posts: 8
Thanks: 1
nightowl is on a distinguished road
Default

Anybody who can help me with this?
nightowl is offline  
Reply With Quote
Old 03-05-2009, 06:31 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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;
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 03-06-2009, 11:22 AM   #4 (permalink)
The Wanderer
 
Join Date: Jan 2009
Posts: 8
Thanks: 1
nightowl is on a distinguished road
Default

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...
nightowl is offline  
Reply With Quote
Old 04-05-2009, 01:26 AM   #5 (permalink)
The Visitor
 
Join Date: Apr 2009
Posts: 1
Thanks: 0
wtyqqqqqqqqqiru is on a distinguished road
Default

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

See answer on stackoverflow: http://stackoverflow.com/questions/4...ined-variables
wtyqqqqqqqqqiru is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some help with PHPTAL Tanax General 13 02-06-2009 03:31 PM
What do you think about PHPTAL? awuehr Libraries & Extensions 27 01-23-2009 12:43 PM
Is there a function to list all "active" variables Dave Absolute Beginners 3 06-05-2008 04:03 AM
Assigning variables and their values from ARRAYS Dave Absolute Beginners 9 06-03-2008 06:33 PM
unset and __destruct Gibou Advanced PHP Programming 5 05-03-2008 11:54 PM


All times are GMT. The time now is 04:49 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design