Re: [SMARTY] Parsing a string as template

"michal.720" <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
I have another problem with "string as a template". I want to display a
tree - 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

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.