views:

112

answers:

2

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 using it when variable is a matrix. Then needed is tal:repeat and I don't know how check each elements of matrix in tal:condition

How fix it in PHPTAL side?

+2  A: 
<tag tal:condition="php:!empty(var)">Some text</tag>
nuqqsa
A: 

tal:condition evaluates '' and arrays with count($array)==0 as false.

If by martix you mean n-dimensional array, then you'll have to wrtite function that checks it the way you want and use it like in nuqqsa's answer.

porneL