phptal

Zebra Striping with PHPTAL?

I'm trying out PHPTAL and I want to render a table with zebra stripes. I'm looping through a simple php assoc array ($_SERVER). Note that I don't want to use jQuery or anything like that, I'm trying to learn PHPTAL usage! Currently I have it working like this (too verbose for my liking): <tr tal:repeat="item server"> <td tal:conditi...

PHPTAL: graceful treatment of undefined variables

If I use a variable that hasn't been put into the scope, PHPTAL throws an exception. Is there any way of making PHPTAL fall back to graceful defaults, for example evaluating to false in a boolean context, to a blank in a string context, etc? ...

PHPTAL and nested templates. Possible?

I've been playing around with PHPTAL for the last couple of days. Overall I really like it. It's been much easier to get into than most others I've looked into. I am having one particular problem, though. Here's the issue. I am trying to nest two templates. Let's say InnerClass has this template: <div>Hello World!</div> OuterClass ha...

Cleanup Symfonys View Templates

I'm evaluating the PHP webframework: Symfony for a project. Everything is quite well organized so far, except for the view templates which suffer from an unreadable/error prone mix of html and php (I was trying to adapt the views to use clean urls and that just turned out to be an exercise in "spot the delimiters"). Is there any methods...

PHPTAL i18n Call to a member function on a non-object Error

I'm using PHPTAL in my project I'm able to successfully implement it almost all the cases except when I want to use its i18n services. I constantly get errors "Call to a member function on a non-object" I've tried searching the net forums etc. but not found any solution, will really appreciate if somebody can help me out. ...

PHPTAL Nested Repeat

Hello guys, I am having an problem trying to achieve a nested repeat in PHPTAL: <tr tal:repeat="business analysis_result"> <td>${business/trading_name}</td> <tal:block tal:repeat="selected_key selected_keys"> <td>HOW??????</td> <---problem </tal:block> </tr> basically I want to have the of inne...

Checking for empty variable in PHPTAL condition

In PHPTAL tal:condition can check is variable empty? Something like that: < tag tal:condition="var" >Some text< /tag > but the value of variable is like that: <?php $variable = ''; $Tpl->var = $variable; ?> And it's a problem 'cause PHPTAL that value '' interpreting like not empty value and condition return true. Next problem is u...

PHPTAL and specyfic table

I have to create specyfic table in PHPTAL. so I have array like that: $tab = array('item1', 'item2', 'item3', 'item4'); Final table should be look like that: <table> <tr> <td>Item1</td> <td>Item2</td> </tr> <tr> <td>Item3</td> <td>Item4</td> </tr> </table> So I was trying use tal:cond...

phptal: how do I repeatedly add attributes?

Hello there, I got a phptal template question, I have an associative array which contains HTML attribute information, eg attrs['href'] = 'www.google.com'; attrs['id'] = 'the_link'; ... Is there a way to use the "repeat" to loop through my array and generate the attributes dynamically? (I know how to do it statically) so I can have ...

How do I conditionally add an id attribute in TAL (PHPTAL)?

I'm creating a form elements template file in PHPTAL. I would like to be able to OPTIONALLY pass in an id attribute for a field... So far the code looks like this: <xml> <tal:block metal:define-macro="text"> <label tal:condition="php: !isset(hideLabel) || isset(hideLabel) && !hideLabel">${field/label}</label> <input name="${n...