6.0.0-beta1
7/26/25

[#1558] in templates allow to check if array members exist
Summary in templates allow to check if array members exist
Queue Horde Framework Packages
Type Enhancement
State Resolved
Priority 1. Low
Owners Horde Developers (at)
Requester vilius (at) lnk (dot) lt
Created 03/16/2005 (7437 days ago)
Due
Updated 01/12/2006 (7135 days ago)
Assigned 03/16/2005 (7437 days ago)
Resolved 01/12/2006 (7135 days ago)
Milestone
Patch No

History
01/12/2006 04:35:32 PM Michael Slusarz Comment #4
State ⇒ Resolved
Reply to this comment
This was actually a quite serious problem since there are at least 
several places in IMP alone where loops inside of loops are required - 
and without if statements it is impossible to accomplish this.  This 
has been implemented in HEAD and Horde 3.1.0.
07/22/2005 06:02:50 PM Chuck Hagenbuch Comment #3
State ⇒ Rejected
Reply to this comment
I finally had a look into this, and this isn't going to change. The 
code that sets things up needs to be responsible for setting any 
fields that you want to test against to false or array().



Why? Because Template doesn't look for what's in the template; it 
takes the data you give it and puts it into whatever it finds. So if 
you don't tell it about an index, it won't go find it.



So just set 'actions' => array() or => false, and this will work fine.
03/16/2005 12:42:31 PM Jan Schneider Comment #2
Assigned to Horde DevelopersHorde Developers
State ⇒ Assigned
Reply to this comment
It is, and I found this annoying already too. I think the Template 
code needs to be fixed to support IFs for array members.
03/16/2005 09:28:42 AM vilius (at) lnk (dot) lt Comment #1
State ⇒ New
Priority ⇒ 1. Low
Type ⇒ Enhancement
Summary ⇒ in templates allow to check if array members exist
Queue ⇒ Horde Framework Packages
Reply to this comment
To better illustrate what I have on my mind I'll show you some code 
from Agora.



------- threads.php -----------

/* Set up the template tags. */

$template = &new Horde_Template();

$template->set('threads', $threads_list, true);



------ templates/threads.html ---------

  <loop:threads>

  <tr>

   <td class="<tag:threads.class /> nowrap">

    <tag:threads.link /><tag:threads.message_subject /></a>

    <span class="small">

     [<loop:threads.actions><divider:threads.actions>, 
</divider:threads.actions><tag:threads.actions 
/></loop:threads.actions>]

    </span>

   </td>



You can note, that if threads.actions doesn't exist, you only see [, ] 
in generated html code. And we cannot check it with 
<if:threads.actions></if:threads.actions> because template engine only 
can check top level array members for this, e.g. threads.



Hope that's understandable :)

Saved Queries