2011-05-12 35 views
0

.Quickの質問 - 私は、次の作業の構文があります。私のPHPTAL構文に何が間違っていますか?

<td tal:define="owner record/owner_id; user user/id; mode php:(owner eq user)?'_edit':'_view'; linkname php:(owner eq user)?'Edit':'View';"> 
    <a href="index.php?-table=${table}&amp;-action=${mode}&amp;id=${record/id}">${linkname}</a> 
</td> 

を私が使用できるように期待していた短い:

ために owneruserを定義する必要がない、すなわち
<td tal:define="mode php:(record.owner_id eq user.id)?'_edit':'_view';linkname php:(record.owner_id eq user.id)?'Edit':'View';"> 
    <a href="index.php?-table=${table}&amp;-action=${mode}&amp;id=${record/id}">${linkname}</a> 
</td> 

php:試験のためにそれらに得るために。

私の質問は、どのようにphp:コンテキストでドット構文が間違っているのですか?テンプレート内のPHPを変更せずに、これを表現する簡単な方法がありますか?

答えて

1

recorduserがオブジェクト(クラスのインスタンス)である限り、この構文は問題ありません。 、その後、あなたが必要とする:あなたがTALES式を使用する場合

tal:define="mode php:(record['owner_id'] eq user['id']) 

、PHPTALはあなたのためのオブジェクト/配列差を割り出し、あなたがphp:を使用している場合は、オブジェクトと配列の間の違いに注意する必要があり

関連する問題