|  | Posted by "michal.720" on 06/23/15 11:19 
I have another problem with "string as a template". I want to display atree - employees in company. I have an array with users, each user in
 array has a "tree_level" (a number from 1 up).
 
 There is one If, one Else If and one Else in my template. In each block
 is the same smarty code
 {$sub_users[su].name_first} {$sub_users[su].name_last}
 ({$sub_users[su].position})
 and some markup - UL / LI tags.
 
 I don't want to have the same code three times (open new level, same
 level, close level).
 
 What will you recommend me?
 1] New block modifier
 {tree}
 {$user.name_first} {$user.name_last}, ({$user.position})
 {/tree}
 And parse content of this block with new smarty resource - string or
 
 2] New smarty plugin (template designers will not be able to modify it's
 output)
 {tree->display}
 
 3] ....?
 
 I didn't have any problems with resources like $_SESSION or strings.
 
 Thanks for any advice
 Michal
 
 Monte Ohrt wrote:
 
 > About the easiest way I've handled this is two templates:
 >
 > email_subject.tpl
 > email_body.tpl
 >
 > then
 >
 > $subject = $smarty->fetch('email_subject.tpl');
 > $body = $smarty->fetch('email_body.tpl');
 >
 >
 > Yes, this requires one extra template, but it keeps the content
 > controlled from templates and avoids all the extra
 > capture/caching/resource hoopla that would be needed otherwise. Using
 > separate templates also clearly defines the separation of
 > subject/body, and is obvious to the template designer what each is for.
 >
 > Monte
  Navigation: [Reply to this message] |