Re: [SMARTY] Assign a template to a variable....
| From: | Peter Bowyer | Date: | Mon, 27 May 2002 19:52:01 +0000 |
| Subject: | Re: [SMARTY] Assign a template to a variable.... | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4408@lists.php.net to get a copy of this message | ||
Hi,
Not sure I understand you fully but I'll try and answer.
At 20:12 27/05/02 +0200, Gandalf wrote:
How about removable sections like PHPLib templates? {section name=foo loop=1 show=$show_foo} This is my form {sectionelse} // Or we could stick this in a separate block... {/section} PHP: if ($form == TRUE) {I have been trying to find out how to do this for nearly half a day now, but i failed. Let's say i have a file called index.tpl. And i also have a file which contains a form called form.tpl. Now i want the form to be in my index.tpl so index.tpl would look like this: <html> blah blah <table blah blah> <tr> <td> {$form}</td> <tr> </table> ..... And i do not want the form to be displayed all the time, rather i want the form to be shown only if $form is TRUE, else it should display a nonbreakingspace ( ). So my two questions are: How can i display a template inside a template and also how can i tell the template index.tpl to show either the form or a nonbreakingspace WITHOUT having to use smarty's {if} {else} etc.. functions (cause the second i have to do that, it is IMHO not a template anymore, no offence taken).
$smarty->assign('show_foo', 1)
}
I think this may do what you want?
The programmer would set $show_foo depending on whether or not that section (block) should show. The designer doesn't have to worry about it.
Code's untested, but I'm starting to move my templates to this kind of logic...
Peter